Nishand's Blog

Welcome to my personal blog, All the information in this bogs is my ideas,findings and thoughts on .Net, Asp.Net and SharePoint.
ALL POSTING ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND

How to hide subsite's GlobalNavigation nodes/tabs through SharePoint API?

 

When we create a site either through UI or OM, it will not come as a tab unless you check the option ‘Site Actions-->Site Setting-->Navigation-->Show subsites to true’.

On checking the option results in displaying all the subsites as ‘Tabs’. If you want to hide some of them programmatically, you need to change the ‘__GlobalNavigationExcludes’ property from the property bag of SPWeb object.

Consider I have a site with 10 subsites, I enabled the option Site Actions--> Site Settings-->Navigation--> Show subsites to 'true, I can see now 10 addtional tabs, If I say SPWeb.Navigation.GlobalNodes.Count wont return a value approx equal to 10.

 

SPSite site = new SPSite("http://nishandv3:100/Sites/DevSite/");

SPWeb web = site.OpenWeb();

string strGlobalNavigationExcludes = web.AllProperties["__GlobalNavigationExcludes"].ToString();

web.AllProperties["__GlobalNavigationExcludes"] = strGlobalNavigationExcludes + "{569F3E30-F9AF-44d5-A52C-47670FC3FEAC}";

// 569F3E30-F9AF-44d5-A52C-47670FC3FEAC" is the GUID of the web you want to hide from the navigation.

web.Update();

 

Hope this helps!

Published Monday, September 10, 2007 11:29 PM by nishandv

Comments

 

MSDN Blog Postings » How to hide subsite's GlobalNavigation nodes/tabs through SharePoint API? said:

September 10, 2007 9:28 PM
 

hilkean1 said:

It is a greate Post. but with one small error. Between the old (strGlobalNavigationExcludes) and the new Guid you have to add an semikolon (;). Otherwise the complete collection crashes after an iisreset.

September 21, 2007 7:11 AM
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker