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

Forums / General Discussions / Unpublished page showing up in custom navigation after 4.2 upgrade

Unpublished page showing up in custom navigation after 4.2 upgrade

4 posts, 1 answered
  1. Josh Anderson
    Josh Anderson avatar
    48 posts
    Registered:
    15 Dec 2005
    09 Sep 2011
    Link to this post
    After our upgrade to 4.2, it appears that the custom navigation control we created is now displaying links for pages that aren't published and are not selected to show up in navigation. I don't know if there was some change to how the SiteMapDataSource looks at pages or what.

    Here's the simple code for how we compile the list of pages:

    SiteMapDataSource1.StartingNodeUrl = StartingUrl;
    RadSiteMap1.DataBind();
     
    var currentNode = SiteMapBase.GetActualCurrentNode(); // RadSiteMap1.SelectedNode;
    var selected = RadSiteMap1.Nodes.FindNodeByText(currentNode.Title);
    if (selected != null)
        selected.CssClass = "active";

    You can see that the only thing we're doing here is adding the "active" CSS class so that we can achieve custom styling to indicate the current selected page. The ASCX page has no real customization:

    <asp:SiteMapDataSource runat="server" ID="SiteMapDataSource1" ShowStartingNode="false" />
    <telerik:RadSiteMap runat="server" ID="RadSiteMap1" DataSourceID="SiteMapDataSource1" ></telerik:RadSiteMap>

    Interestingly, our standard RadMenu does not show this page in its list. Any idea how I can get this unpublished page not to show up, short of deleting it?

    Update: You can see this in action by going to http://www.telephonypartners.com/about-us. Note that there is a "Careers" link on the left sidebar, but not in the main horizontal site menu bar. Also note that if you click the careers link you get a 404 error (because the page is unpublished).
  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    14 Sep 2011
    Link to this post
    Hi Josh Anderson,

     There have been changes in the SiteMapDataSource since 4.2, that's why you should use our SitefinitySiteMapDataSource which has all the custom logic for not showing unpublished pages and so on implemented. Here's what namespace you will have to add:

    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls" TagPrefix="navcontrols" %>
     
    <navcontrols:SitefinitySiteMapDataSource ID="SitemapDataSource1" runat="server" />
    Best wishes,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  3. Vivid Group
    Vivid Group avatar
    8 posts
    Registered:
    01 Dec 2009
    20 Feb 2012
    Link to this post

    Using the standard RadMenu does not resolve the issue. I can still see the unpublished page nodes

    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls" TagPrefix="navcontrols" %> 

    <navcontrols:SitefinitySiteMapDataSource ID="SitemapDataSource1" runat="server" />

     

    I need to show published version of the draft page and hide unpublished pages in the navigation

    Can I control it using an extension method?

    public static bool ShowNodeInSideNav(this Telerik.Sitefinity.Web.PageSiteNode node, HttpContext currentContext)

            {

                bool isViewable = false;

     

                if (node.ShowInNavigation &&  node.IsAccessibleToUser(currentContext))

                {

                    if (node.Status == ContentLifecycleStatus.Live || node.Status == ContentLifecycleStatus.Master)

                    {

                        isViewable = true;

                    }

                }

     

                return isViewable;

            }

    The code displays the draft node but also display unpublished pages

     

     

  4. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    22 Feb 2012
    Link to this post
    Hi,

    Try the following check:

    item.Visible == true&&
     
    item.Status == ContentLifecycleStatus.Live &&
     
    item.PublicationDate <= DateTime.UtcNow &&
     
    (item.ExpirationDate == null|| item.ExpirationDate > DateTime.UtcNow);

    All the best,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
4 posts, 1 answered