Hi everyone, I'm Chris Richard. Today I want to take some time to walk you through some features of navigation in MOSS 2007 from an implementation perspective, and show you some things you can do to customize your Web site's navigation.
First, let's explore some of the navigation-related features in MOSS 2007. I'll start off by provisioning a new site collection based on the Publishing Portal template. I've created a few sub-sites and pages in my site collection, with a hierarchy like so:
Root Site (NavigationExample)Web Site - 1 Web Page - 1.P1 Web Site - 2 Web Site - 2.1 Web Site - 2.1.1 Web Page - 2.1.P1 Web Page - 2.1.P2 Web Site - 2.2 Web Page - 2.P1 Web Site - 3 Web Site - 3.1
Let's take a look at what gets setup automatically for you in terms of navigation. When I visit the Web Site- 2 subsite I see the following:
Let's first talk about the horizontal or top navigation menu. This menu is declared on the master page that this site is using (I've pulled out the markup below):
<SharePoint:AspMenu ID="GlobalNav" Runat="server"
The vertical or left navigation menu is declared in a similar way, but with slightly different properties. Note that I removed some of the less interesting properties (at least for this discussion) like styling so as to focus on the more interesting ones. Also, these properties are identical to those available on the ASP.NET 2.0 Menu control (http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.aspx).
Now on to the data source which I found by looking for a declaration with ID="GlobalNavDataSource":
The PortalSiteMapDataSource is a MOSS-specific data source which knows how to retrieve data from a PortalSiteMapProvider object and expose this data according to the ASP.NET hierarchical data source interface. As such, it specifies the name of the provider it wishes to use to retrieve data via the SiteMapProvider property. We'll look more closely at these providers shortly.
As can be seen, the root node, "NavigationExample" is now included in the menu. Also, since I didn't adjust the StaticDisplayLevels, none of the items beneath NavigationExample are included (to see them, simply change this property to "2" to see both NavigationExample and the Web Site - 1, Web Site - 2, etc. items). Whether or not you want to include the starting node is completely a matter of preference. On this site the root Web site is always shown above the horizontal navigation menu, next to the logo (see above), so it doesn't make much sense to include another link in the menu.
The PortalSiteMapProvider object mentioned above is the true source of the hierarchical data and it provides this to the data source. The PortalSiteMapProvider retrieves nodes from WSS's SPNavigation store which provides the ability to create static links and groupings. These items are then merged with the site collection structure (i.e. dynamic items representing Web sites and Web pages) and then security trimming is applied so that users only see items for which they have permission to navigate.
Named providers are declared in the application's web.config file in order to make them widely accessible. The declarations of the two most important PortalSiteMapProviders are shown below (slightly modified for clarity):
<add name="CombinedNavSiteMapProvider" description="CMS provider for Combined navigation"
NavigationType="Combined" EncodeOutput="true" />
<add name="CurrentNavSiteMapProvider" description="CMS provider for Current navigation"
NavigationType="Current" EncodeOutput="true" />
Note that the name of the first provider, "CombinedNavSiteMapProvider", matches the value specified for the SiteMapProvider property of the data source we examined earlier. From this it becomes clear that the horizontal menu is ultimately supplied by this provider object.
Let's talk about these provider properties in more detail:
Other properties available on the provider but not shown in the above declarations include:
There are also a group of properties that control the provider's inclusion of various node types:
I think I'll break here for now. Next time we'll look at the Navigation Settings page which you can use to easily configuration navigation on a per-Web site basis. I'll also make sure to tie up all the loose ends I've unraveled in the course of this post.
--Chris Richard, ECM Developer