How to:Extend the Navigation Provider

You can extend the navigation provider in Microsoft Office SharePoint Server 2007 by deriving a custom provider class from any of the default site map providers. Deriving from an Office SharePoint Server 2007 site map provider supplies several benefits such as navigation node caching and security trimming. The following code example derives from the PortalSiteMapProvider class and demonstrates how to add items to the site map provider. Although the site map provider classes have approximately twenty abstract or virtual methods, only a small number must be overridden and implemented in a custom site map provider.
  • Create a Microsoft Visual C# class library project with following code, add the required references, and then build the project.

using System;using System.Collections.Generic;using System.Text;using Microsoft.SharePoint.Publishing;using Microsoft.SharePoint.Publishing.Navigation;using System.Web;using System.Web.UI.WebControls;using System.Configuration;

namespace MyCustomNav


public class Navigation: PortalSiteMapProvider


public override SiteMapNodeCollection

GetChildNodes(System.Web.SiteMapNode node)

{PortalSiteMapNode pNode = node as PortalSiteMapNode;

if (pNode != null)

{if (pNode.Type == NodeTypes.Area)

{SiteMapNodeCollection nodeColl = base.GetChildNodes(pNode);

SiteMapNode childNode = new

SiteMapNode(this, “”,

“”, “Microsoft”);

SiteMapNode childNode1 = new

SiteMapNode(this, “”,



SiteMapNodeCollection test = new


childNode.ChildNodes = test;return nodeColl;

}elsereturn base.GetChildNodes(pNode);

}elsereturn new SiteMapNodeCollection();


  • Copy the .dll file you created in step 1, and then paste it into the Office SharePoint Server 2007 virtual directory’s bin folder.
  • Create the following entry in the web.config file for the Web application, and then set the trust level to Full.

<add name=”MyCustomNavigationProvider” type=”MyCustomNav.Navigation, MyCustomNav”

  • Create a custom master page and add the following code under the top navigation’s ContentPlaceHolder element.

<sharepoint:aspmenuid=”topnavigationmenu” runat=”server” datasourceid=”topSiteMap1″ enableviewstate=”false” accesskey=””>” Orientation=”Horizontal” StaticDisplayLevels=”1″ MaximumDynamicDisplayLevels=”3″ DynamicHorizontalOffset=”0″ StaticPopoutImageUrl=”/_layouts/images/menudark.gif” StaticPopoutImageTextFormatString=”” DynamicHoverStyle-BackColor=”#CBE3F0″ SkipLinkText=”” StaticSubMenuIndent=”0″ CssClass=”ms-topNavContainer”>

<staticmenustyle/><staticmenuitemstyle cssclass=”ms-topnav” itemspacing=”0px”/><staticselectedstyle cssclass=”ms-topnavselected”/><statichoverstyle cssclass=”ms-topNavHover”/><dynamicmenustyle backcolor=”#F2F3F4″ bordercolor=”#A7B4CE” borderwidth=”1px”/><dynamicmenuitemstyle cssclass=”ms-topNavFlyOuts”>/><dynamicselectedstyle cssclass=”ms-topNavFlyOutsSelected”/></SharePoint:AspMenu>

<asp:sitemapdatasource showstartingnode=”False” sitemapprovider=”MyCustomNavigationProvider” id=”topSiteMap1″ runat=”server” startfromcurrentnode=”true”>

  • Reset Microsoft Internet Information Server (IIS). Your SharePoint site should now show the updated navigation from the extended navigation provider.

Still more to come…



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s