Publishing Navigation Secrets, Part 1

February 8 2010 5 comments

SharePoint 2007 (and 2010) has a very comprehensive but somewhat confusing navigation system built-in. The main limitation of SharePoint navigation system is, that it doesn’t work over site collection boundaries, and by default it produces real horrible <table> structured output. The output can be altered by writing a custom menu control adapter (or by using CSS friendly control adapters). The site collection boundary problem cannot be easily worked out while still supporting the out-of-the-box features like security trimming, audience targeting, authored links, link hiding, caching, etc. That’s why I don’t look into navigation over site collection boundary limits in this article (maybe SharePoint Blues will come back to it later on).

At the first part of navigation series, I explain the SharePoint publishing navigation internals, and in the second part I will go in the details of how to parametrize navigation.

How Does The SharePoint Default Publishing Navigation Work?

Collaboration Quick Launch MenuLet’s start by looking at a quick launch navigation. When you create a Collaboration Portal, you get a quick launch menu that looks like the picture on the right. How does it end up containing the navigation elements? The data provider for this menu is defined as following in default.master master page:

<SharePoint:DelegateControl
 runat="server"
 ControlId="QuickLaunchDataSource">
  <Template_Controls>
    <asp:SiteMapDataSource
     SiteMapProvider="SPNavigationProvider"
     ShowStartingNode="False"
     id="QuickLaunchSiteMap"
     StartingNodeUrl="sid:1025"
     runat="server"/>
  </Template_Controls>
</SharePoint:DelegateControl>

The template controls section is basically ignored here (I think the WSS uses that?) as the delegate control is replaced by SharePoint delegate. The delegate is configured using a SharePoint Feature (and it can easily be replaced by a custom Feature).

By default it’s defined at the 12\TEMPLATE\Features\Navigation\NavigationSiteSettings.xml -file:

<Control
 Id="QuickLaunchDataSource"
 Sequence="50"
 ControlClass=
 "Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapDataSource"
 ControlAssembly=
 "Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral,...">
  <Property Name="ID">QuickLaunchSiteMap</Property>        
  <Property Name="SiteMapProvider">CurrentNavSiteMapProvider</Property>
  <Property Name="EnableViewState">false</Property>
  <Property Name="StartFromCurrentNode">true</Property>
  <Property Name="StartingNodeOffset">0</Property>
  <Property Name="ShowStartingNode">false</Property>
  <Property Name="TrimNonCurrentTypes">Heading</Property>        
</Control>

The delegate on the other hand points to a provider defined at web.config for the current web application (specifically CurrentNavSiteMapProvider):

<add
 name="CurrentNavSiteMapProvider"
 description="CMS provider for Current navigation"
 type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider..."
 NavigationType="Current"
 EncodeOutput="true"
 IncludePages="PerWeb"
 IncludeHeadings="true"
 IncludeAuthoredLinks="true" />

And that’s about it. Now let’s make this a little bit more obvious and straightforward, and let’s edit our default.master -file. I start by replacing the delegate control with PortalSiteMapDataSource control (that’s what we usually do in our custom master pages – while the delegate controls give you some flexibility, you lose in readability and clarity):

<PublishingNavigation:PortalSiteMapDataSource
 ID="QuickLaunchSiteMap"
 Runat="server"
 SiteMapProvider="CurrentNavSiteMapProvider"
 EnableViewState="false"
 StartFromCurrentNode="true"
 StartingNodeOffset="0"
 ShowStartingNode="false"
 TrimNonCurrentTypes="Heading"
 PortalProvider-NavigationType="Current"
 PortalProvider-EncodeOutput="true"
 PortalProvider-IncludePages="PerWeb"
 PortalProvider-IncludeHeadings="true"
 PortalProvider-IncludeAuthoredLinks="true"/>

What we did, we basically combined the above (delegate control and web.config attributes) in a PortalSiteMapDataSource control. The menu behavior stayed the same. The navigation configuration is now practically in one place, in a master page (or alternatively in a user control). Needless to say the same applies to top navigation too.

In the next article in this series, I will explain each of these attributes used in navigation in a detail, and maybe I will also show you some new ones.

Popularity: 11% [?]

5 comments to “Publishing Navigation Secrets, Part 1”

  1. Hi I’m doing some browsing around and was wondering if you’ve tried SharePoint 2010 yet?

  2. Allen says:

    Hi,

    Nice article. just wondering if you have written part 2 yet.
    cheers,

    Allen

  3. Woody says:

    Its all about hacking the PublishingNavigation:PortalSiteMapDataSource

  4. Peter says:

    Has anyone tried to replace QuickLaunchDataSource and TopNavigationDataSource at the same time? It seams that only the higher Sequence Control wins

  5. Mark says:

    Is there way to make these changes without directly manipulating the web.config file? (E.g. with a feature or solution deployment?) When you have a large farm, often with multiple we applications, you don’t want to be going in and manually monkeying with a bunch of web.config files. Everything should be deployable from the .wsp

Leave a Reply