Saturday, May 05, 2007

Publishing style navigation in WSS v3

Tuesday, February 27, 2007, 12:02:43 AM E. Shupps
While working with some custom site definitions based on the built-in STS (Team Site) definition I came across an annoying navigation issue that derailed me for a couple of hours. It turns out the the drop-down functionality in the top navigation bar, which works perfectly well in the Publishing and Collaboration Portal definitions, is disabled in the Team Site definition. After digging around in the object model for a while and trying a few different combinations, I found the solution in the menu settings contained within the default master page.
To enable drop-down menu functionality, locate the following block of code in the Default.Master page (/_catalog/masterpage/default.master in the site collection or \12\Template\Global\default.master on the file system):
< asp:SiteMapDataSource
ShowStartingNode="False"
SiteMapProvider="SPNavigationProvider"
id="topSiteMap"
runat="server"
StartingNodeUrl="sid:1002" / >
This sets the data source for the menu control and its associated parameters. Each Site Map Provider is defined in the <> section of web.config. The SPNavigationProvider entry looks like this:
< name="SPNavigationProvider" type="Microsoft.SharePoint.Navigation.SPNavigationProvider, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
If you locate this entry in web.config you will notice another entry for "SPSiteMapProvider" immediately below it. After much trial and error I discovered that this is the data source that is required for the drop-down menus. To enable it, change the SiteMapDataSource settings in default.master (or your custom master page) to the following:
ShowStartingNode="True"
SiteMapProvider="SPSiteMapProvider"
id="topSiteMap"
runat="server" />
The navigation menu will now use the SPSiteMapProvider data source which contains all the nodes in the current site collection. Depending upon your requirements, you may also wish to modify the settings for the default number of static and dynamic levels (flyouts) the navigation control displays. To do that, adjust the following settings within the <> control:
StaticDisplayLevels="2"MaximumDynamicDisplayLevels="1"
Adjusting these values up or down will increase or decrease the number of levels. Be advised that setting the levels to a higher value may impact performance, as the control will need to fetch the relevant information from the database and build the complete menu structure before the page can finish loading.

No comments:

Post a Comment