Thursday, April 7, 2011

Overriding Top Navigation Menu for SharePoint System Pages

I just had a request from a client to have the same navigation everywhere in a site collection including system layouts pages (settings.aspx, mngfield.aspx, etc...). I had a custom masterpage which used a custom navigation provider, but the system pages in the layouts directory never picked up the custom provider data.

I took a look at the settings.aspx page to figure out why/how the SiteMapDataSource was being overridden, and sure enough the TopNavBar.asxc controltemplate is being loaded:


Next, I check out the TopNavBar.ascx (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES) to figure out what was going on. You'll see in the image below that the TopNavBar.ascx is overriding the topNavigationDelegate control and using SPNavigationProvider instead of the custom provider defined in my masterpage.


Having figured that out, the next step was simply to override the delegate control using a control element in a feature. After deploying and activating the feature, the various layouts pages had the correct navigation item.


IMPORTANT NOTE:
Make sure to test which navigation menus are affected by the feature. The number of places affected (site, subsite, site collection, web application, Farm) will vary depending on how you scope the feature (Farm, Site, Web, etc...)