Extending Navigation to Cross-Site Collection Boundaries

You can extend one of SharePoint's site map providers to enable global navigation. One way to do this is to use XML to customize the SPXmlContentMapProvider class.

Using the SPXmlContentMapProvider Class

The SPXmlContentMapProvider class is an XML-based site map provider that is used by SharePoint. This provider can read a navigation structure from any standard site map. SharePoint uses the SPXmlContentMapProvider class to provide the navigation structures for application pages that are located in the _layouts folder. Because the SPXmlContentMapProvider class reads the navigation structures from an XML file, it is not limited to a site collection boundary. The XML file can include URIs that are outside of the current site collection.

There are two ways to use XML to customize the SPXmlContentMapProvider class:

  • You can create a custom site map.
  • You can create a site map that will be merged into SharePoint's site map.

The next sections describe each of these.

Creating a Custom Site Map

A site map contains a hierarchical structure of sitemap elements. You must create an XML file that incorporates each site collection into this common structure. The site map file must have the .sitemap file name extension. After you create the site map, copy it to the _app_bin folder of the SharePoint Web application. Finally, use the SharePoint Web application's Web.config file to configure an instance of the SPXmlContentMapProvider class. Copy the site map file to the Web front-end server. Use SharePoint's deployment infrastructure to do this.

Merging XML Fragments with the layouts.sitemap File

SharePoint allows developers to deploy files to the _layouts folder of a Web front-end server. It also allows developers to provide XML fragments of a site structure that can be merged into the layouts.sitemap file. The name of the XML file that contains the new site structure must begin with layouts.sitemap. For example, a valid file name is layouts.sitemap.contosoglobalnavigation.xml.

When SharePoint starts, it scans all the XML files that are in the _layouts folder whose names begin with layouts.sitemap. It merges the contents of these files with the layouts.sitemap file that is located in the Web application's _app_bin folder. Because SharePoint is already configured to read the site map from the layouts.sitemap file, you do not need to configure an instance of the SPXmlContentMapProvider class.

Considerations for Multiple Web Front-End Servers

Both creating a custom site map and merging XML fragments present challenges if you have multiple Web front-end servers. Because the SPXmlContentMapProvider class is a file-based site map provider, you must ensure that the XML file that defines your navigation structure is installed on every Web front-end server in the farm.

SharePoint does not provide a way to synchronize the files in the _app_bin folder with all of the Web front-end servers in a farm. If you are merging XML fragments, SharePoint's deployment infrastructure can deploy the XML file to those servers. However, the API that merges those fragments with the layouts.sitemap file only works on a single Web front-end server. Developers or system administrators must manually perform the merges on all the servers each time that the site map changes.

Another consideration for using the SPXmlContentMapProvider class is that SharePoint does not provide a user interface to manage the custom navigation structure. This can make it difficult to work with XML files that have a complex structure.

Home page on MSDN | Community site