Recently I faced with interesting problem. There are a lot of publishing sites in the intranet and we needed to update current navigation settings on all sites with “Display the same navigation items as the parent site” option:
I created a small tool which updates current navigation on all sites:
As you can see it is pretty simple: it goes through all sites recursively and updates the navigation settings. The tool successfully updated all sites and left navigation became inherited from parent sites on all sub sites. However on some sub sites (not on all of them) in Site Settings > Navigation option “Display the current site, the navigation items below the current site, and the current site's siblings” was shown:
The strange thing was that as I said left navigation correctly showed the navigation items from the parent site on all sites. Moreover PublishingWeb.Navigation.InheritCurrent was set to true, because these sites were not updated when I ran the tool second time.
I checked the logic of the code behind class of the AreaNavigationSettings.aspx page (Microsoft.SharePoint.Publishing.Internal.CodeBehind.AreaNavigationSettingsPage). It has the following controls of HtmlInputRadioButton type for each option for the current navigation settings:
|inheritLeftNavRadioButton||Display the same navigation items as the parent site|
|showSiblingsLeftNavRadioButton||Display the current site, the navigation items below the current site, and the current site's siblings|
|uniqueLeftNavRadioButton||Display only the navigation items below the current site|
That’s how it uses these controls:
As you can see even if these 3 controls belong to the same group, via project model it is possible to specify both properties PublishingWeb.Navigation.InheritCurrent and PublishingWeb.Navigation.ShowSiblings to true. Via UI it is not possible. And in such situation Sharepoint will show “Display the current site, the navigation items below the current site, and the current site's siblings” because appropriate control (showSiblingsLeftNavRadioButton) is initialized after control with “Display the same navigation items as the parent site” title (inheritLeftNavRadioButton). This is error-prone implementation because if before displaying the AreaNavigationSettings.aspx page both properties were set to true, user didn’t changed anything and clicked Ok – after it PublishingWeb.Navigation.InheritCurrent will set to false and PublishingWeb.Navigation.ShowSiblings will remain true (as I said above according to the logic of the code behind these properties can not be set to true simultaneously via UI).
So I just add the one line of code in order to fix my tool and after that navigation settings for all sites showed correct value (“Display the same navigation items as the parent site”):
Keep it in mind when you will modify navigation settings via object model.