Making sub-sites inherit managed navigation settings of root site in SharePoint 2013

In SharePoint 2013 when creating sub-sites (at least through the UI), and you set the new sub-site to inherit the global nav from the parent site, and the parent site uses managed navigation, you will find that the global nav of the sub-site does not correctly inherit all the managed navigation links from the parent site.

This has been reported by the links below:

http://blog.jussipalo.com/2013/03/sharepoint-2013-managed-navigation-not_12.html
http://social.msdn.microsoft.com/Forums/en-US/sharepointgeneral/thread/87a00e4f-59eb-4e36-a7f0-6535bb1f748a

You can fix this by re-applying the navigation settings of the new sub-site after it has been created (as discussed in the first link).

However, when you are provisioning many sites, you may want to fix this by code. Put the code below in a feature receiver and activate the feature for each sub-site:

var web = properties.Feature.Parent as SPWeb;
var rootWeb = web.Site.RootWeb;

var rootWebNavSettings = new WebNavigationSettings(rootWeb);
var thisWebNavSettings = new WebNavigationSettings(web);

thisWebNavSettings.GlobalNavigation.Source = StandardNavigationSource.InheritFromParentWeb;
thisWebNavSettings.GlobalNavigation.TermStoreId = rootWebNavSettings.GlobalNavigation.TermStoreId;
thisWebNavSettings.GlobalNavigation.TermSetId = rootWebNavSettings.GlobalNavigation.TermSetId;
thisWebNavSettings.Update();

The WebNavigationSettings class is defined in the Microsoft.SharePoint.Publishing.Navigation namespace of the Microsoft.SharePoint.Publishing.dll.

Advertisements

About Bernado

Based in Australia, I am a freelance SharePoint and Dynamics CRM developer. I love developing innovative solutions that address business and everyday problems. Feel free to contact me if you think I can help you with your SharePoint or CRM implementation.
This entry was posted in Managed Navigation, SharePoint 2013. Bookmark the permalink.

2 Responses to Making sub-sites inherit managed navigation settings of root site in SharePoint 2013

  1. tapani says:

    No go with SharePoint 365 since Microsoft.SharePoint.Publishing.Navigation cannot be used.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s