0

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?

1

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/

  • 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
0

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;

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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