I'm creating a custom team site from a site definition and I can't seem to set the site to display the same navigation items as the parent site for the Global Navigation. I've tried using this code:

web.Navigation.UseShared = true;

as well as trying with the PublishingWeb object:

PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web);
pubWeb.Navigation.InheritGlobal = true;

I've also tried setting it via my onet.xml file by setting it here:

 <!-- NavigationProperties Feature-->
    <Feature ID="541F5F57-C847-4e16-B59A-B31E90E6F9EA">
      <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
        <Property Key="InheritGlobalNavigation" Value="true"/>

I'm finding the only way I can set it is via powershell:

new-SPWeb "http://dev.site.com/subsite" -template "MySiteDefinitions#0"  -useparenttopnav -name "Subsite"

but I can't use this at runtime. Has anyone had luck with this?

  • Your top code looks fine, that's what I've done. You don't have a custom masterpage or navigation provider for it, do you?
    – Andy Burns
    Jun 15 '11 at 9:48
  • Actually I further inspected it today and I agree the top code is the right way - the value is getting set properly in my WebProvisioned event receiver. The problem I'm seeing is that it's getting reset at some point afterwards (inspecting with SharePoint Manager shows it working and set in a Version "1", then at some point it turns to Version "2" and it's unset again). I'll have to dig deeper into why that's happening.
    – Sean Regan
    Jun 15 '11 at 17:49

In your onet.xml file after activate publishing feature you can specify these properties:

<Feature ID="541F5F57-C847-4e16-B59A-B31E90E6F9EA">
  <!-- Per-Web Portal Navigation Properties-->
  <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
    <Property Key="InheritGlobalNavigation" Value="true"/>
    <Property Key="InheritCurrentNavigation" Value="true"/>
    <Property Key="IncludeSubSites" Value="true"/>
    <Property Key="ShowSiblings" Value="false"/>
    <Property Key="IncludePages" Value="false"/>
    <Property Key="OrderingMethod" Value="Automatic"/>
    <Property Key="AutomaticSortingMathod" Value="CreatedDate"/>
    <Property Key="SortAscending" Value="true"/>

This works well for me.

Meybe this will help,


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.