Unpublished page showing up in custom navigation after 4.2 u

Posted by Community Admin on 03-Aug-2018 21:46

Unpublished page showing up in custom navigation after 4.2 upgrade

All Replies

Posted by Community Admin on 09-Sep-2011 00:00

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).

Posted by Community Admin on 14-Sep-2011 00:00

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

Posted by Community Admin on 20-Feb-2012 00:00

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
 
 

Posted by Community Admin on 22-Feb-2012 00:00

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

This thread is closed