Skip to main content

Creating a Two Tier Global Navigation

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
image

Example 2: Fed Ex
image

Example 3: Wall Street Journal
image 

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:

image

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:

image

Have fun customizing, and drop me a line if you have created something similar!

Comments

Hector Insua said…
Thanks Erik Great Post!!
Omar Molinares said…
Thanks Erick for your excellent article!
fromonesource said…
Is there any way to get sitemap nodes beneath the first sitemap node? In your examples, you have a second tier beneath the first item in tier one. I have run into issues doing that because the sitemap providers only allow for one root sitemap node. Would you be able to share your sitemap xml and perhaps some more code from your master page? Thanks for the great article.
BSpurlock said…
When I try to run this I get a runtime error. I went back and check everything but I cannot get it to work. I'm a graphic Designer learning SharePoint so if anyone can point me in the right direction to find what is wrong I would greatly appeciate it.
Anonymous said…
Very nice article.
Sendil said…
Hi, I couldn't achieve wat u did in( 2 tier) ur blog pls help me to sort out
Laleh said…
I tried your solution, but I have a unexpected error when I run my page,Probably some thing was missed in my master page ,would you pleas put your master page here
Thanks
Erik Swenson said…
I see that some people are getting error's. It is really important that you have the ID's matching, and that you reference the correct datasource for your sitemap provider. Also if your XML is not correct in the site map provider it will throw an error.
Laleh said…
1.I changed the Ids and it works fine,but I need some clarification,I want to have relation between these 2 horizental navigation tabs,I mean when I click on the one of upper tab the childs should be displayed in lower horizental navigation tab(no drop dwon list)

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.
John Fox said…
Any way we can get more of the masterpage as an example. i can get the single tier but not the double tier working. keeps throwing an unexpected error But overall very helpful. just need that second tier to get it implemented on my site
Erik Swenson said…
John Fox, I have created a new post with the source files: http://erikswenson.blogspot.com/2010/02/update-creating-two-tier-global.html
John Fox said…
Thanks a lot man. i got it working great but some of our remote sites with slower connections are still having issues. I'm working through them and appreciate the help
John Fox said…
is there a way to make the second menu i have, reading from the "topsitemap" allow drop downs. when i make it a sub on the native sp navigation it just puts it right beside it unstead of creating a drop down
Erik Swenson said…
I have created a new post on how to use this method to create a Two Tier Global navigation for SharePoint 2010.

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"
Elena said…
Thanks Erik, Great Post!!

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
Anonymous said…
Work your tool in SharePoint Foundation? I want to get an tier global navigation.
Anonymous said…
Thanks so much for your branding blogs for 2010, very simple to follow and helpful as I transition from 2007.

If anyone does have articles specific to meeting accessibility guidelines (tweaks required) I would appreciate any links.

aterese_au@yahoo.com.au
Anonymous said…
Thanks Erik....While trying this I am getting error as 'Sitemap is not found'..

One more : Will I get the horizontal display at the second level navigation with this approach???
Unknown said…
Nice post. Simple and to the point. This is exactly what I'm trying to do, and I think I've more-or-less set it up to work this way. However, I'm not seeing any security trimming.

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?
Erik Swenson said…
Rich Mills,
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.
Anonymous said…
Hi,

I can't see multi-levels in application pages, how can I see them?

Thanks

Orrin
Anonymous said…
Excellent post.I want to thank you for this informative read, I really
appreciate sharing this great post. Keep up your work.
Web design quote
Unknown said…
Hi,In our experience, for the initial Web Design Cochin, too often customers spend too long thinking about the initial visual design and not enough time on the navigation structure.Thanks.....

Popular posts from this blog

SharePoint 2010 Base CSS Classes

This will be the first of many SharePoint 2010 posts. I will be focusing on a few of the main CSS classes used for SharePoint 2010 Public Beta. As the product becomes more final there might be some changes to the class names but I will be sure to create a new post if that happens. This will be quite a lengthy but it should be helpful. The default CSS given below are just highlights of the full CSS attributes for that class. I will be using a basic team site as my base for the screenshots. Here is a basic structure of the main areas that I will cover. Ribbon Row Table Row Left Site Actions Navigate Up Edit Tab List Browse Page Table Row Right Give Feedback Welcome Menu Workspace Body Container Title Row Title

SharePoint 2010 Content Query for Blog Posts

I hope this post will help many of you feel comfortable with using the Content Query Web Part. In this post I will walk you through the process of creating a content query web part and configuring it to show custom field types. I will also give details on how to use XSLT to stylize and format the data being pulled. I will be using the following scenario as an example. Say that you had a site collection with a top level publishing site. This publishing site would display a the most recent blog posts from all blog sites within its own site collection. To solve this problem we will use a Content Query Web Part and a customized ItemStyle.xsl using XSLT. Please note that the “SharePoint Server Publishing Infrastructure” needs to be enabled at the site collection to display the content query web part. Step 1: Add a Content Query Web Part to Page Navigate to the site that you want the blog posts to show up and click on edit page. Under Editing Tools in the Ribbon, Click on

SharePoint 2013 Responsive Table Columns

I have been wanting to write this one for a while now. It is really amazing how UX is really finding is way into everything that we use and interact with. From Custom applications both mobile and on a desktop to document management or large data visualizations. There is always room for better usability and new concepts. SharePoint lists and library functionality really has not changed much for the past 10 years... I remember back in 2003 when I saw the same table/grid based views of documents and list items that exists in SharePoint 2013. But now we can look at them in a whole new way! In this video blog you will see how to create a responsive CSS table so that when the browser size is reduced it will hide specific columns. However hiding data is not always the right thing to do. What if a user needed those columns to filter on or to use for comparison to another document? Well that is where the custom jQuery Column chooser comes in. It allows you to see what columns are displ