1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / News module problem list on master pager SF3.2.2

News module problem list on master pager SF3.2.2

2 posts, 0 answered
  1. Bill Deihl
    Bill Deihl avatar
    6 posts
    Registered:
    28 Sep 2007
    13 Jul 2008
    Link to this post

    I have a master page with a newsview module and it displays as expected.

    The master page newsview links to a page for the full story view. The full story displays correctly as well.

    Where it gets sticky, when I click on a story in the master page news module, it also shows the individual story. So now the news story is in two places and I have lost my list.

    I want it to always show the list on the master page no matter what happens at the page level.

    Any help would be appreciated.

    Bill

  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    16 Jul 2008
    Link to this post
    Hello Bill,

    Unfortunately, the required functionality cannot be achieved with the original NewsView control because the display mode of the control automatically changes to SingleItem when an item is selected. As a workaround you can create your own control that overrides the base class like this:

    using Telerik.News.WebControls; 
    using Telerik.Cms.Engine; 
    using Telerik.Web; 
     
    /// <summary> 
    /// Summary description for NewsViewExtender 
    /// </summary> 
    namespace Telerik.News.WebControls 
        public class NewsViewExtender : NewsView 
        { 
            protected override void CreateChildControls() 
            { 
                this.Controls.Clear(); 
     
                // Set the current page index depending on the display mode 
                if (!String.IsNullOrEmpty(this.Context.Request[this.PageKey]) && this.CurrentPage <= 1) 
                { 
                    this.CurrentPage = Convert.ToInt32(this.Context.Request[this.PageKey]); 
                } 
                // Determine the display mode which relies on various params 
                // - Tag and Category which can be displayed in both single and list mode 
                // - item id which triggers the single-item mode 
                if (!String.IsNullOrEmpty(this.Context.Request[this.TagItemKey])) 
                { 
                    this.TagID = new Guid(this.Context.Request[this.TagItemKey]); 
                } 
                else if (!String.IsNullOrEmpty(this.Context.Request[this.CategoryKey])) 
                { 
                    if (CategoryKeyType == Telerik.Cms.Engine.WebControls.Categories.CategoryKeyTypes.ID) 
                    { 
                        try 
                        { 
                            this.CategoryID = new Guid(this.Context.Request[this.CategoryKey]); 
                        } 
                        catch (FormatException) 
                        { 
                            // Invalid guid! don't add CategoryID 
                        } 
                    } 
                    else 
                    { 
                        ICategory cat = this.Manager.GetCategory(this.Context.Request[this.CategoryKey]); 
                        if (cat != null
                            this.CategoryID = cat.ID; 
                    } 
                } 
                if (this.Context.Items.Contains(this.ContentItemKey)) 
                    this.itemId = (Guid)((IUrlRewriteData)this.Context.Items[this.ContentItemKey]).Data; 
                else if (!String.IsNullOrEmpty(this.Context.Request[this.ContentItemKey])) 
                    this.itemId = new Guid(this.Context.Request[this.ContentItemKey]); 
     
                if (!this.IsValidItem(itemId)) 
                    this.itemId = Guid.Empty; 
     
                if (this.DisplayMode == DisplayModes.SingleItem && this.itemId != Guid.Empty) 
                { 
                    this.displayModeImpl = DisplayModes.SingleItem; 
                    this.CreateSingleContent(); 
                    this.Controls.Add(this.SingleContainer); 
                } 
                else 
                { 
                    if (this.DisplayMode == DisplayModes.Tags || (this.DisplayMode == DisplayModes.Auto && this.TagID != Guid.Empty)) 
                    { 
                        this.displayModeImpl = DisplayModes.Tags; 
                        this.CreateContentList(this.displayModeImpl, this.TagID); 
                    } 
                    else if (this.DisplayMode == DisplayModes.Category || (this.DisplayMode == DisplayModes.Auto && this.CategoryID != Guid.Empty)) 
                    { 
                        this.displayModeImpl = DisplayModes.Category; 
                        this.CreateContentList(this.displayModeImpl, this.CategoryID); 
                    } 
                    else if (this.DisplayMode == DisplayModes.ItemList || this.DisplayMode == DisplayModes.Auto) 
                    { 
                        this.displayModeImpl = DisplayModes.ItemList; 
                        this.CreateContentList(this.displayModeImpl, Guid.Empty); 
                    } 
     
                    this.Controls.Add(this.ListContainer); 
                    this.ListContainer.RepeaterControl.DataBind(); 
                } 
            } 
        } 

    Please note that it is necessary to set the DisplayMode property of the NewsViewExtender control used in the page
    to SingleItem. Also, you should register the new control in the <toolboxControls> section of the project web.config file to display it in the toolbox:

    <add name="News View Extender" section="News" type="Telerik.News.WebControls.NewsViewExtender, App_Code"/> 

    Do let us know if this helps.


    All the best,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
2 posts, 0 answered