Publishing Navigation Secrets, Part 1

February 8 2010 13 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: 3% [?]

13 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

  6. Having read this I believed it was very enlightening. I appreciate you finding the time and energy
    to put this article together. I once again find myself spending a significant amount of time
    both reading and leaving comments. But so what,
    it was still worthwhile!

  7. I have been surfing online more than three hours today, but I never found any fascinating article like yours. It is lovely worth sufficient for me. In my opinion, if all website owners and bloggers made good content as you did, the web might be much more helpful than ever before.

  8. click here says:

    The on-line shopping is gaining continuous reputation and is becoming a growing trend among shoppers. The advantages of web buying are as well attractive for men and women to resist. It is time to accept the new ways of purchasing and enjoy its rewards. With an increasingly extra competitive company planet, enterprises understand the ought to attain their targeted shoppers inside a non intrusive way. There’s lots of promoting rewards to listing your provider in a web based enterprise directory. It is actually an effective, affordable, and important aspect of increasing home business exposure, as well as gaining a competitive edge over these organizations within your sector.

  9. Man,amazing blog you have right here. Loads of awesome stories and similar facts!!!

    Do you offer any specific information associated with telemarketing lists?

    my website … proven strategies to get new business leads

  10. Now i am not optimistic where by you might be getting your data, having said that beneficial subject jasa pembuatan toko online. We has to spend an afternoon examining a great deal more as well as comprehension extra. Many thanks for good details I’d been searching for this data for my goal.

  11. Wonderful site. A lot of useful information here.
    I’m sending it to several pals ans additionally sharing in delicious.
    And naturally, thanks in your effort!

  12. Fatima says:

    I have visited your site and I think that the content could be of interest to our web site visitors.

  13. Asking questions are truly pleasant thing if you are not understanding anything totally, however this post offers pleasant understanding
    yet.

Leave a Reply