Partager via


Controlling navigation options from the onet.xml

During past weeks I have been creating few customer POCs to demostrate the excellent WCM features of the MOSS 2007. Since the MOSS publishing features are deployed over the WSS using standard feature framework, we can configure the provisioning of the sites directly from the onet.xml. In this blog entry, I'll declare the concepts behind this possibility and the possible properties, which can be set.

 

Introduction

If you have played around the onet.xml files included as out-of-the-box in the MOSS (Publishing template etc.), you have most likely noticed the publishing navigation feature dependencies in the WebFeatures element as in xml block below.

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

So what does this really mean? Basically we are making a binding to publishing navigation feature and configuring it by using properties, which the handler is capable to handle. So the ID given in the onet.xml is a reference to NavigationProperties feature, which can be found from the following folder (by default):

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\NavigationProperties

And the feature.xml file from here contains following information:

<Feature Id="541F5F57-C847-4e16-B59A-B31E90E6F9EA"
               Title="Portal Navigation Properties"
               Description="Set per-site navigation properties."
               Version="12.0.0.0"
               Scope="Web"
               Hidden="TRUE"
               ReceiverAssembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
               ReceiverClass="Microsoft.SharePoint.Publishing.NavigationFeatureHandler"
               xmlns="https://schemas.microsoft.com/sharepoint/">
               <ElementManifests>
                    <ElementManifest Location="NavigationSiteSettings.xml"/>
               </ElementManifests>
</Feature>

As you can see, ReceiveAssebly and ReceiverClass attributes are set and there for when the actions are performed for the feature, "custom code" is executed. As declared already above, the custom code is aware of some parameters which can be set for the feature and based on these parameters, the receiver handler modifies the SPPublishingWeb object's properties.

 

Supported parameters

So what are the parameters supported by the NavigationFeatureHandler class and how do they affect compared to settings done from the user interface. I'll declare the supported parameters one-by-one and compare the settings to modifications done from the user interface (Site Actions -> Site Settings -> Navigation) .

 

IncludeInGlobalNavigation, IncludeInCurrentNavigation 

Controls the IncludeInGlobalNavigation and IncludeInCurrentNavigation properties of the SPPublishingWeb. In user interface this functionality is controlled by using following options.

 

InheritGlobalNavigation

This paremeters controls the global navigation options. If set the true, we will get the same outcome by selecting "Display the same navigation items as the parent site".

 

InheritCurrentNavigation

This controls the inheritance of the current navigation. If set the true, we would get the same results as by selecting the "Display the same navigation items as the parent site" from the user interface (the first option from the picture below)

 

 

ShowSiblings

If set the TRUE, the outcome is the same options as the “Display the current site, the navigation items below the current site, and the current site's siblings” option in the user interface (second option from the picture below). Note that the IncludeSubSites and IncludePages parameters also affects to outcome.

 

IncludeSubSites

This is same as the "Show subsites" option in the user interface . Note that if the current navigation has been set to show the same navigation items as the parent site, this option has no meaning.

 

IncludePages

This is same as the "Show subsites" option in the user interface . Note that if the current navigation has been set to show the same navigation items as the parent site, this option has no meaning.

 

OrderingMethod

This option affects to ordering of the navigation items. Note that the final outcome depends also from the AutomaticSortingMathod and the SortAscending properties.

Possible values

Automatic - Sort all node types automatically, and group pages after other types. 

Manual - Sort all types manually. 

ManualWithAutomaticPageSorting - Sort all types except pages manually. If pages are included, sort them automatically and group them after all other types. 

 

AutomaticSortingMathod and  SortAscending

These controls the sorting of the navigation items. Possible outcome depends on numerous other properties, since for example the AutomaticSortingMathod property has only meaning, if the OrderingMethod has been set to ManualWithAutomaticPageSorting.

Note. It's not a typo... it's really AutomaticSortingMathod...

Possible values for the AutomaticSortingMathod property

CreatedDate - Sort items by time of creation. 

LastModifiedDate - Sort items by time of last modification. 

Title - Sort items alphabetically by title. 

 

Final words

As you can see, you can configure all the same options directly from the onet.xml, as you can do from the user interface. Other thing to notice is the possibilities provided by the Feature Receiver concept, which gives flexible way to execute custom code during the site provisioning (or anytime the feature is otherwise activated).

More information concerning the functionalities declared here can be found from the SDK.

 

PS. I'll try to find some time to write similar article concerning the other possibilities of the WCM features (how to limit the page layouts, how to limit the web templates shown in UI, how to configure master page etc.). Stay tuned...

[Update] - The following post with information concerning the other publishing feature configurations has been released. Check the details from here.

Comments

  • Anonymous
    October 14, 2007
    In the previous post, I promised to try to find time to share additional information concerning the onet.xml

  • Anonymous
    January 20, 2008
    When setting OrderingMethod to "Manual", is there a way to move the individual navigation items into required positions? Do I need to create a custom feature which sorts the items, after the main navigation feature has been installed?

  • Anonymous
    January 21, 2008
    The comment has been removed

  • Anonymous
    March 28, 2008
    Thanks for the post! I was wondering why i can't hide pages the same way, at least they won't hide the way i try to hide them ;-) i have a site definition for a publishing site where i defined a module 'Content' to deploy some default pages <Module Name="Content"        Url="$Resources:cmscore,List_Pages_UrlName;"        Path="">   <File Url="sitemap.aspx"         Type="GhostableInLibrary"         Path="default.aspx"         Level="Draft" >         <Property Name="Title"                   Value="Sitemap" />         <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/PageLayoutDefault.aspx,~SiteCollection/_catalogs/masterpage/PageLayoutDefault.aspx" />         <Property Name="IncludeInGlobalNavigation"                   Value="false" />   </File> <Module>   According to the SDK, the PublishingPage class exposes a public property called 'IncludeInGlobalNavigation'. Can somebody point me to the right direction.

  • Anonymous
    April 10, 2008
    Good question... and actually quote logical due the misleading element names within the Module element structures. The properties (Property element) here are actually columns within the list (site columns of the content type of the page) where the page is uploaded... not actual properties of the .NET class... There's no direct way of setting the actual .NET class properties from the Module / File elements. If this is however required, you have to create a feature receiver, which manipulates the actual objects using APIs.

  • Anonymous
    September 24, 2008
    can i include navigation groups(dropdownlists) to topnavi trough site definition(onet.xml). would like to create group "documentlibs" with the dropdownitems pointing to documentlibs

  • Anonymous
    November 22, 2008
    Really good post - thanks. I wonder why MS cannot come up with a documentation like this...

  • Anonymous
    September 14, 2009
    Some real interesting facts of navigation properties:

  • It is a typo from MS for AutomaticSortingMethod it is typed as AutomaticSortingMathod
  • While specifying navigation properties following properties take value in small case:-
  • InheritGlobalNavigation (true/false)

  • InheritCurrentNavigation (true/false)

  • IncludeSubSites (true/false) while some of the properties accept values in Camel Case

  • IncludePages (True/False)

  • Anonymous
    June 18, 2012
    When I use several of these properties not all seem to work.

  • Anonymous
    June 19, 2012
    Hi Danny, there are different combinations of these properties whcih work and what doesn't work. Notice also that this was written for SharePoitn 2007. 2010 has different set of options and combinations. .vesku

  • Anonymous
    June 03, 2013
    hi, what about 2013 new settings for navigation (setting structural and managed navigation)? is there any attribute for setting the type of navigation by this feature?

  • Anonymous
    January 27, 2017
    How can i set the Navigation Settings in ONET.XML with set Global Navigation with structural navigation check show pages and Current navigation structural navigation with uncheck show subsites and show pages options. My Code is :