Freigeben über


MOSS Navigation Deep-Dive - Part 2

Welcome back! I'm going to continue with my overview of Navigation in MOSS 2007. If you missed part one, I'd definitely suggest reading that first. We're going to start off today by looking at the configuration options available on the Navigation Settings page which is accessible through the Site Actions menu or off of the Site Settings page.

PortalSiteMapProviders examine inheritance settings and various other navigation related properties defined on Web sites in order to provide data. Navigation is very site-centric, and each Web site in a site collection can determine the way the navigation items beneath it are displayed, all the way down to the next site(s). As such, each site has a variety of navigation options that can be manipulated at the Navigation Settings page, accessible through the Site Actions menu. Below is a screenshot of this page for Web Site - 2.

The first two options, "Show subsites" and "Show pages", control whether or not these two types of items are automatically included in navigation. Note that disabling both of these options won't result in each and every Web site and Web page disappearing from navigation. Rather, beneath the particular Web site we're dealing with (Web Site - 2), items of these types (Web Site - 2.1, Web Site - 2.2, Web Page - 2.P1) won't show up.

The Sorting options are fairly self-explanatory. Selecting manual sorting allows you to rearrange the items manually using the sorting pane in a different section we'll look at shortly.  Selecting automatic sorting will result in these nodes being arranged for you using the specified sorting criteria although you can still use the sorting pane to move items from one heading to another.

The next two sections of options have more interesting consequences and will allow us to touch back to the discussion about PortalSiteMapDataSource and the StartFromCurrentNode property from earlier. Note that these sections are not shown when visiting the root Web site's Navigation Settings page so check out this page for a subsite of the root. Two options are available pertaining to global navigation. The first, "Display the same navigation items as the parent site", is the default for non-root sites and indicates that the Web site should use whichever global navigation items its parent site does. This is also referred to as "inheriting" navigation items. The second, "Display the navigation items below the current site", indicates that this site's global navigation items should be populated from the items below the site. There are similar options for current navigation although the default value is notably different. As I mentioned, these sections are not shown for the root site and this is because the root site has no parent to inherit navigation items from and therefore must display its own navigation items.

These settings affect where in the hierarchy the data source starts from when visiting the site in question. As noted before, even though the data source declaration includes StartFromCurrentNode="true", the MOSS data source walks up hierarchy from the current node until it finds a Web site that does not inherit and starts from there instead. If the data source is attached to a Global provider, it looks to the global inheritance settings whereas a Current type provider looks at the current inheritance settings.

The default settings cause global navigation to inherit in most cases, eventually starting from the root site (which obviously cannot inherit). Changing this setting for a specific site somewhere down the hierarchy causes global navigation to be "re-anchored" for that site and any beneath it. For example, take a look at the screenshots below, taken while visiting Web Site - 2 and Web Site - 2.1 after switching Web Site - 2's global navigation to "Display the navigation items below the current site".

In both cases, the global navigation now starts from Web Site - 2 and display the items beneath it.

Current navigation, on the other hand, is not set to inherit by default and so usually does start at the current node. This also means that setting current navigation to "Display the same navigation items as the parent site" for a particular site will usually cause the data source to start just one site up, rather than follow an inheritance chain all the way to the root site. The middle option for current navigation, "Display the current site, the navigation items below the current site, and the current site's siblings" is a slight twist on things. Rather than starting from the current site, the data source's starting node is moved up exactly one level, so as to include the current site and the site's siblings, and any children of the sibling nodes are automatically trimmed out. This effect can be seen in the above screenshots on the vertical navigation menus (which is hooked up to a Current provider). Looking at the image on the left, even though Web Site - 1 and Web Site - 3 have child nodes beneath them we are currently visiting Web Site - 2 and therefore the mentioned sites are siblings of the current site and have their children trimmed.

The next section in the settings page includes the navigation editing and sorting pane. With this you can rearrange any subsites and pages of this particular Web site, as well as manually add new links and headings. Headings may link to somewhere or may be unlinked and they aren't just for grouping links; you can group sub-sites and pages under headings as well. The control also has some advanced accessibility features. You can change your selection using the [Up-Arrow] and [Down-Arrow] keys, move the selected item up or down using [Ctrl]+[UpArrow] or [Ctrl]+[DownArrow], and you can also use [Tab] and [Shift]+[Tab] to move between the selected item and the toolbar. Users with screen readers can activate WSS's "More Accessible Mode" to enable a rendering that is more conducive to this method of interaction.

Above, I added a "Pages" heading using the "Add Heading..." and moved the only page in this site under it by selecting the Page and clicking "Move Up" and "Move Down". After clicking "OK", the navigation menus on the site look like this:

So our heading shows up, but what about the page beneath it? Further, why does it show up only in the vertical menu and not the horizontal menu? First, the page isn't showing up because this would require 3 levels of hierarchy to be shown by the menu: Web Site - 2, Pages, Web Page - 2.P1. We could simply add one more static or dynamic level to the menu declaration but I want to keep my menu showing only 2 levels. Instead I'll go back to the Navigation Settings page and, in the Current Navigation section, choose to "Display only the navigation items below the current site", resulting in the following:

I no longer see Web Site - 2 and its siblings, but I can see more of the items beneath the current site now. As for the issue of this heading not showing up in the top navigation menu, we'll need to return to the data source declaration we looked at earlier, particularly the last two properties:

 
<PublishingNavigation:PortalSiteMapDataSource ID="GlobalNavDataSource"
        ...
        TrimNonCurrentTypes="Heading"
    TreatStartingNodeAsCurrent="true" />

The first of these properties specifies that any items of type Heading not directly beneath the current node should be trimmed. Now at first it seems like this criterion is met: we are visiting Web Site - 2 and the Pages heading is directly beneath it. However, the second property specifies that the current node for trimming purposes should not be the currently visited item, but should be whichever node the data source starts from. In this case, the data source is starting from the root site and so only Headings directly beneath the root site will be shown.

There are number of available trimming options that will include a larger subset of the headings, and you can turn off trimming completely by removing reference to any of these trimming properties. See the previous post for information about these trimming options.

Lastly, I wanted to point out a somewhat confusing detail. If we return to the Navigation Settings page for just a moment, you'll notice that toggling between the two Global Navigation options results in a change in the way that the editing and sorting pane is displayed. When the option is set to "Display the navigation items below the current site" the pane is split into a Global Navigation and Current Navigation sections allowing separate configuration of global navigation items and current navigation items. However, with "Display the same navigation items as the parent site" there is no such separation:

"Display the same navigation items as the parent site"

"Display the navigation items below the current site"

This behavior is linked to the Combined provider which is usually used to drive the top navigation menus. You may recall that the Combined provider uses items and settings from global navigation when the site does not inherit its global navigation items, and uses the items and settings from current navigation when the site does inherit global navigation. This means that it is useless to try and arrange items in Global navigation if the site inherits global navigation because the current navigation items will be used instead.

You may then wonder about the Global type provider that I earlier recommended you not use. Won't this provider always use the items and settings from global navigation? Shouldn't I have a choice about whether or not I want to configure global and current navigation differently? This was the original intent but as it turns out there are restrictions on WSS's SPNavigation store which do not allow the storage of items in the TopNavigationBar while the site is set to inherit global navigation (note: for those familiar with WSS navigation, this is equivalent to having SPNavigation.UseShared set to true for a particular SPWeb). As a result, it is not possible to configure global navigation separately from current navigation unless the site displays its own global navigation items, rendering the Global provider useless (although it is used internally, so don't remove the Global provider definition from the web.config).

At this point we've completed a fairly thorough trip through the navigation features in MOSS 2007. I hope you'll find this information useful in getting navigation on your MOSS site to behave just how you want it to. Please feel free to leave questions and comments and I'll do my best to respond wherever possible.

--Chris Richard, ECM Developer

Comments

  • Anonymous
    March 23, 2010
    Is there a way to have a heading under another heading. This i need it for achiving the 3 level navigation of published pages. Has anyone found the solution 4 this problem?