Unpublished page showing up in custom navigation after 4.2 upgrade
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"
;
<
asp:SiteMapDataSource
runat
=
"server"
ID
=
"SiteMapDataSource1"
ShowStartingNode
=
"false"
/>
<
telerik:RadSiteMap
runat
=
"server"
ID
=
"RadSiteMap1"
DataSourceID
=
"SiteMapDataSource1"
></
telerik:RadSiteMap
>
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"
/>
Hi,
Try the following check:
item.Visible ==
true
&&
item.Status == ContentLifecycleStatus.Live &&
item.PublicationDate <= DateTime.UtcNow &&
(item.ExpirationDate ==
null
|| item.ExpirationDate > DateTime.UtcNow);