30
novembre
2008
SharePoint navigation – SPNavigationNode.IsVisible returns always true
novembre
2008
SPNavigationNode.IsVisible returns always true no matter whether the web is marked as hidden or visible in the navigation.
Example :
using(SPSite Site = new SPSite(URL))
{
using(SPWeb Web = Site.OpenWeb())
{
SPNavigationNodeCollection Nodes = Web.Navigation.TopNavigationBar;
foreach(SPNavigationNode Node in Nodes)
{
if(Node.IsVisible)...//returns always true even if the node is marked as hidden..
}
}
}
{
using(SPWeb Web = Site.OpenWeb())
{
SPNavigationNodeCollection Nodes = Web.Navigation.TopNavigationBar;
foreach(SPNavigationNode Node in Nodes)
{
if(Node.IsVisible)...//returns always true even if the node is marked as hidden..
}
}
}
Here is how you can workaround that, not wonderful in terms of performance but…
…
foreach(SPNavigationNode Node in Nodes)
{
using(SPSite Site = new SPSite(Node.Url))
{
using(SPWeb Web = Site.OpenWeb())
{
if(PublishingWeb.IsPublishingWeb(Web))
{
PublishingWeb PubWeb = PublishingWeb.GetPublishingWeb(Web);
if(PubWeb.IncludeInGlobalNavigation)
//marked as visible
else
//marked as hidden
}
}
}
}
{
using(SPSite Site = new SPSite(Node.Url))
{
using(SPWeb Web = Site.OpenWeb())
{
if(PublishingWeb.IsPublishingWeb(Web))
{
PublishingWeb PubWeb = PublishingWeb.GetPublishingWeb(Web);
if(PubWeb.IncludeInGlobalNavigation)
//marked as visible
else
//marked as hidden
}
}
}
}
Articles récents
- Demo App de type SharePoint-Hosted montrant l’utilisation des API REST dans SharePoint 2013
- Webcast sur oData
- Problème potential avec des formulaires de liste personnalisés
- Développer et consommer un service oData pour SharePoint 2010
- SharePoint 2010 – Dépasser la limite des 10000 résultats de recherche



Un article de stephane eyskens