Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We have Sharepoint 2007 with WCM enabled. We have several sites. And the Navigation Menu's shows the sites perfectly. So we are able to hide the sites in the Navigation Settings. All the menus will respect this.

My requirement is through code if i have the site name Will i be able to know whether this site is hidden in the Navigation or not?

share|improve this question
add comment

2 Answers

If your web is publishing web,You can use PublishingWeb.IncludeInCurrentNavigation or PublishingWeb.IncludeInGlobalNavigation, depending on you want to check for current or global navigation.

Otherwise, you can use a simple function like below :

bool IsWebVisible(SPWeb webToCheck)
{

SPNavigationNode node= SPContext.Current.Site.RootWeb.TopNavigationBar.GetNodeByUrl(webToCheck.Url);

// or SPNavigationNode node= SPContext.Current.Site.RootWeb.GlobalNodes.GetNodeByUrl(webToCheck.Url);

// or SPNavigationNode node= SPContext.Current.Site.RootWeb.QuickLaunch.GetNodeByUrl(webToCheck.Url);

 return node.IsVisible;

}
share|improve this answer
add comment

One would think that looking at the SPNavigationNode object there is an IsVisible property which should tell you whether the site is hidden in the navigation or not. But apparently that is not the case for publishing sites (WCM).

See this post which explains how to find out that info for a publishing site:

http://blog.developpez.com/eyskens/p6853/sharepoint/sharepoint-navigation-spnavigationnode-i/

share|improve this answer
    
I will try this out-but it is unfortunate why it is not been part of SPWeb property –  Thomson Aug 29 '11 at 17:08
    
SPWeb is for WSS and WCM is part of MOSS. Basically, MOSS is built on top of WSS just like you dev on top of WSS. So they can't add MOSS functionality to WSS objects, they have to have their own objects. Does that make sense? Thanks. –  Steve Lineberry Aug 29 '11 at 17:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.