Tuesday, November 9, 2010

SharePoint 2010 Common Navigation Across Site Collections

So Microsoft best practice dictates content dbs should be less than 100GB or so, at least that's what I think. Either way, you're here because you have multiple site collections and want to know how to have the same top navigation bar across all the site collections. It took me a few hours to find but here's the solution.

In web.config file, add the following provider


<siteMap defaultProvider="CurrentNavigation" enabled="true">

<providers>

<add name="CustomTopNavProvider" siteMapFile="/_layouts/1033/CustomTopNavMenu.sitemap" type="System.Web.XmlSiteMapProvider,System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>





Add the CustomTopNavMenu.sitemap to the 1033 directory. If you don't know how to create or use a sitemap file just google it.

Open up the master page for each site collection, for 2010 it's v4, probably best to create a copy and all that stuff before editing it.

Find this part of the file. (around line 343)




<SharePoint:AspMenu

  ID="TopNavigationMenuV4"

  Runat="server"

  EnableViewState="false"

  DataSourceID="topSiteMap"

  AccessKey="<%$Resources:wss,navigation_accesskey%>"

  UseSimpleRendering="true"

  UseSeparateCss="false"

  Orientation="Horizontal"

  StaticDisplayLevels="2"

  MaximumDynamicDisplayLevels="1"

  SkipLinkText=""

  CssClass="s4-tn"/>

<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate">

<Template_Controls>

<asp:SiteMapDataSource

  ShowStartingNode="False"

  SiteMapProvider="SPNavigationProvider"

  id="topSiteMap"

  runat="server"

  StartingNodeUrl="sid:1002"/>

</Template_Controls>

</SharePoint:DelegateControl>





and change it to the following:


<SharePoint:AspMenu

  ID="TopNavigationMenuV4"

  Runat="server"

  EnableViewState="false"

  DataSourceID="topSiteMap"

  AccessKey="<%$Resources:wss,navigation_accesskey%>"

  UseSimpleRendering="true"

  UseSeparateCss="false"

  Orientation="Horizontal"

  StaticDisplayLevels="1"

  MaximumDynamicDisplayLevels="4"

  SkipLinkText=""

  CssClass="s4-tn"/>

<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource">

<Template_Controls>

<asp:SiteMapDataSource

  ShowStartingNode="False"

  SiteMapProvider="CustomTopNavProvider"

  id="topSiteMap"

  runat="server"

/>

</Template_Controls>

</SharePoint:DelegateControl>





basically we are setting the SiteMapProvider to the provider we added in the web.config that reads our custom site map file. We don't show the starting node, we remove an ID of the DelegateControl (may or may not be necessary) and then set the StaticDisplayLevels of the ASPMenu to 1 and the MaximumDynamicDisplayLevels to 4. S

Save masterpage, reload page and whamooo, it should work. If not, leave a comment and I'll try to help.

Expanding on this, if you created a web part that could read and update the sitemap file, then users would not necessarily need access to the 1033 folder to update navigation.

UPDATE: after some research, it doesn't seem possible to dynamically update the .sitemap file using a web part. I suggest putting a custom folder in the 1033 folder for navigation and share it out to those who need to be able to update it. It will need to be update on all front end web servers.

8 comments:

public key infrastructure said...

Using same top navigation bar across all the site collections on a group of sites that are interlinked in one way or other.It always looks good and feels like on same main site and other linked sites.Sometime a site of a company with different service areas can be made with this concept

Anonymous said...

The first comment is from a bot or a dipshit.

Unknown said...

I followed instructions to a "T". Received no errors.
Don't know if it worked or not. I'm not sure what I'm supposed to be seeing.

Unknown said...

Apparently not exactly to a "T". Went through process again, this time in Designer received an error "Menu - TopNavigationMenuv4Error parsing control: The SiteMapProvider 'CustomTopNavProvider' cannot be found."
Can you shed some light on this error. By the way, both web.config and CustomTopNavMenu should be in layouts/1033? right?

المتوكل على الله said...

شركة تنظيف خزانات بالرياض
شركة مكافحة حشرات بالرياض
شركة مكافحة النمل الابيض بالرياض
ارخص شركة تركيب مكيفات بالرياض

jack_harper said...

Need Nursing assignment help? Get an expert touch at an affordable price.

Robert Walt said...

Thanks to British essay writers for helping those students who have writing issues.

Anonymous said...

Trigonometry Assignment Help
Trigonometry is an exceptional branch of mathematics that arrangements with lengths and points of triangles. It must be painstakingly noticed that science has been seen to be the foe and a thistle in the tissue for understudies. We understand that Trigonometry is a hard subject, and many students search on the web for Trigonometry solutions and assistance for projects. Archlite Assignments are a renowned Trigonometry Assignment Help provider.

Understudies appear to confront expanding travails and difficulties in examining arithmetic. Assignments on such topics like trigonometry appear to expand their weight. The uneasiness level ascents thus do the feeling of anxiety. The derivations of such occasions could be viewed as restless evenings and increment level of dissatisfaction. Discerning choices and arrangements should be produced to help the reason for the understudies. for more visit us at - https://archliteassignments.co.uk/trigonometry-assignment-help/