Creating Custom Navigation That Crosses Site Collection Boundaries

You can implement global navigation by creating a custom navigation solution that can cross site collections. One reason to do this is to store your site map in a centralized location. A central location reduces the costs of deploying and maintaining your navigation solution.

Implementing a Custom Site Map Provider

If you want a custom solution, you must implement a custom site map provider. This allows you to make your site map useable by any navigational control you choose, such as a menu, a breadcrumb or a tree. The ASP.NET framework includes base classes that you can use to create a custom site provider.

For example, the Partner Portal application extends the StaticSiteMapProvider class. This class translates a site map that is in persistent storage to one that is stored in memory. The contents of the site map are read once. This is when the application pool for a Web site starts. The StaticSiteMapProvider class is a good choice when the site map in the persistent store changes infrequently. When the site map in the persistent store does change, the site map provider will not reflect those changes until the application pool recycles.

Using the Hierarchical Configuration

When you implement a custom site map provider, you must decide on a persistent storage mechanism for the site map. There are number of options, including a custom database table, the SharePoint_Config database, or a SharePoint list. The Partner Portal application uses the Configuration Manager that is part of the SharePoint Guidance Library. It stores the entire XML navigation fragment as a single configuration value. In the Partner Portal application when the application pool starts, the Contoso.Common.Navigation.HierarchicalConfigSiteMapProvider reads the XML from the Hierarchical Configuration and then loads it in memory as a site map.

Other Considerations

It is important to thoroughly test the code that implements the custom site map provider. An exception that occurs while the site map provider is initializing can prevent your application from loading, even if the site map provider is not used on a page that a user requests. Also, a faulty site map provider can be difficult to troubleshoot.

One of the drawbacks of a custom site map provider is that SharePoint does not provide a user interface (UI) that allows you to modify the site map at run time. This can make an application's navigation static because it is difficult to add new nodes. On the other hand, SharePoint's site map providers are dynamic. It is simple to update and modify the site structure if you use them. It is possible but potentially time consuming to build a custom UI to modify a site map that is in a persistent store.

Home page on MSDN | Community site