Two tier navigation is not a new concept and has been out for quite a long time. However SharePoint OOTB does not allow you to have a global navigation that spans multiple site collections.
Here are a few examples of a multi tier horizontal navigation.
Example 1: MSDN: Microsoft Developer Network
Example 2: Fed Ex
Example 3: Wall Street Journal
During a recent project I was given the task to create a global navigation that had two tiers like the examples above.
After some investigation my friend Sahil Malik had put together a great blog about creating a consistent navigation across site collections. (Thanks Buddy)
Well this is great and all but his code replaced the OOTB navigation with a custom one. So after some hard thinking I figured out that you could create your own control that drove the tier 1 global navigation (Across site collections) and a tier 2 local navigation (OOTB) that was security trimmed.
To get this to work you should use Shail's post as a guide for code but here are the basic steps:
- Go to: \inetpub\wwwroot\wss\VirtualDirectories\yourwebappname
- Create a back up of the web.config on each of the web applications that you want the two tier navigation
- Add the following to the custom web.config file
<add name="CustomXmlContentMapProvider" siteMapFile="_app_bin/mainMenu.sitemap" type="Microsoft.SharePoint.Navigation.SPXmlContentMapProvider, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
- Go to: \inetpub\wwwroot\wss\VirtualDirectories\yourwebappname\_app_bin
- Create a file called "mainMenu.sitemap" and add in your navigation simular to something like below
<?xml version="1.0" encoding="utf-8" ?>
<siteMap>
<siteMapNode title="Tab 1 Home" url="/Pages/Default.aspx">
<siteMapNode title="My Site" url="http://mysite.company.com/_layouts/mysite.aspx">
<siteMapNode title="My Profile" url="http://mysite.company.com/person.aspx"/>
</siteMapNode>
<siteMapNode title="Collaboration" url="/Collaboration/Pages/Default.aspx"/>
<siteMapNode title="News" url="/news/Pages/Default.aspx">
<siteMapNode title="News 1" url="/news/news1/Pages/default.aspx"/>
<siteMapNode title="News 2" url="/news/news2/Pages/default.aspx"/>
<siteMapNode title="News 3" url="/news/news3/Pages/default.aspx"/>
</siteMapNode>
</siteMapNode>
</siteMap>
Finding out the hard way you cannot have any of the siteMap Node elements have the same url or title...
Please note that if you are placing this custom control on the mysite the relative links will have to be changed to absolute due to the fact that they reside in different web applications.
- Next you will have to add in the custom control to your masterpage. This can be a bit tricky.
- Copy the OOTB navigation control "<asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server">"
- Place this control in a <TR> tag right above the OOTB navigation control
- Like in Sahil's blog post rename the DataSourceID= from in the custom control from "topSiteMap" to "xmlSiteMap"
- You will also need to modify the content placeholder and menu ID's see highlighted items below:
Once you get it finally working your new navigation will have the following functions:
- Tier 1: Global Navigation
- Always Consistent
- Not Security Trimmed
- Manually configured on the server Via XML (I'm sure if you wanted to get tricky you could hook this up to custom list or something...)
- Globally across site collections, web applications and even external applications if you wanted (Basically anything)
- Tier 2: OOTB Local Navigation
- Changes based on site collection
- Security Trimmed
- Configured through the UI
- Only shows navigation within the site collection
So here is a screenshot of the custom two tier global navigation control:
Have fun customizing, and drop me a line if you have created something similar!
Comments
Thanks
2.another thing is it possible to use sitMap as datasourse for both horizental navigation tabs(I supposed to have dynamic data source) and having parent/child relationship between them.
If is it possible can you upload your whole solution included css file.
http://erikswenson.blogspot.com/2010/07/sharepoint-2010-two-tier-global.html
John Fox,
Try changing StaticDisplayLevels to "1" and MaximumDynamicDisplayLevels to more than "2"
I tried your solution in sharepoint 2010. I have 2 tier drop down menu, but I can`t get the example you did in 2007 (for example Wall Street Journal ) with 2 tiers in horizontal without drop down.
Could you help me with this issue please??
Thanks!!
Elena
If anyone does have articles specific to meeting accessibility guidelines (tweaks required) I would appreciate any links.
aterese_au@yahoo.com.au
One more : Will I get the horizontal display at the second level navigation with this approach???
You mentioned that Tier1 is NOT security trimmed, but Tier2 IS security trimmed. Are you actually getting the behavior to work? How do you control whether the menu items appear?
You are correct the top tier is not security trimmed. The second tier should be security trimmed by default since you will be using the OOTB top navigation control which comes standard with the ability to security trim its content. Make sure your second tier (The one on the bottom) is using the OOTB top navigation control.
I can't see multi-levels in application pages, how can I see them?
Thanks
Orrin
appreciate sharing this great post. Keep up your work.
Web design quote