1

I have activated SharePoint Publishing Infrastructure feature provisioned through my web template. But the Navigation (my libraries in QuickLaunch bar) was not visible after publishing feature activation. For showing navigation, I added following feature to my web template:

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

But, I could not see navigation (Libraries in QuickLaunch bar) in my site collection. Then I go to Site settings -> Navigation and select last option (structural navigation) from current navigation option and click ok. I can see Navigation now. But My question is, how can I do this through xml provision in my web template ?

1 Answer 1

1

I have added following code in feature and then add that feature's id to web template which solves my problem

public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWeb web = properties.Feature.Parent as SPWeb;

            PublishingWeb navPublish = PublishingWeb.GetPublishingWeb(web);
            WebNavigationSettings navSettings = new WebNavigationSettings(web);
            navSettings.GlobalNavigation.Source = StandardNavigationSource.PortalProvider; // Structural Navigation
            navSettings.CurrentNavigation.Source = StandardNavigationSource.PortalProvider;
            navPublish.Navigation.OrderingMethod = OrderingMethod.Automatic;
            navPublish.Navigation.AutomaticSortingMethod = AutomaticSortingMethod.Title;

            navPublish.Update();
            navSettings.Update();
            web.Update();

        }
1
  • Thank you for this post - I was struggling with this just recently and didn't think of inserting the code to another feature and activating it from the onet.xml file. Commented Jun 12, 2014 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.