-------------------------------------
Page 81, Listing 5-6: The
NavBars>
<NavBar Name="SharePoint Top Navbar" ID="1002" />
</NavBars>
With this:
<navbars></navbars>
<navbar name="SharePoint Top Navbar" id="1002"></navbar></navbars>
-------------------------------------
This small mistake creates quite a few problems if sites are already created from this site definition and you are not gung-ho about recreating the sites. The major problem is that any navigation setting (sorting, hiding) on global navigation will not get persisted.
You can get past some of the problems with programmatically modifying the global navigation in case you get in to this situation
Let us say you want to hide site from global navigation, here is what you have to do
string siteURL = <
SPSecurity.RunWithElevatedPrivileges(delegate() {
SPSite site = new SPSite(siteURL);
SPWeb web = site.OpenWeb();
if (PublishingWeb.IsPublishingWeb(web))
{
PublishingWeb publish = PublishingWeb.GetPublishingWeb(web);
Console.WriteLine("Site is " + publish.Title.ToString());
Console.WriteLine("Global Navigation current setting:" + publish.IncludeInGlobalNavigation);
publish.IncludeInGlobalNavigation = false;
Console.WriteLine("Global Navigation changed setting:" + publish.IncludeInGlobalNavigation);
publish.Update();
}
});
of course, dont forget to dispose of your SPWeb and SPSite at the end;
No comments:
Post a Comment