Skip to main content

SharePoint 2010 Two Tier Global Navigation

I have been asked quite a few times if the SharePoint 2007 two tier global navigation will work with SharePoint 2010. The answer is yes with a few slight modifications. The approach stays the same: Master Page points to web.config > web.config points to .sitmap file > Page Renders custom navigation control.

The difference between 2007 and 2010 of course is that you want to add the custom site map provider to the new 2010 web.config file. Search for the following in the web.config file: “sitemap”. within the last row add the following:

<add name="DEMOGlobalNavSiteMapProvider" siteMapFile="/_layouts/1033/styles/demo/DemoGlobalNav.sitemap" type="Microsoft.SharePoint.Navigation.SPXmlContentMapProvider, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />

You will notice that I placed my custom sitemap file in the style folder within the layouts directory.

There is also some slight changes to how your reference the navigation control in the 2010 master page. Here is the reference:

<!-- Start Custom Global Navigation -->
                    <div class="s4-lp s4-toplinks">
                                <asp:ContentPlaceHolder id="DemoGlobalNav" runat="server">
    <SharePoint:AspMenu
      ID="demoGlobalNavAspMenu"
      Runat="server"
      EnableViewState="false"
      DataSourceID="demoGlobalNavSiteMapDataSource"
      AccessKey="<%$Resources:wss,navigation_accesskey%>"
      UseSimpleRendering="true"
      UseSeparateCss="false"
      Orientation="Horizontal"
      StaticDisplayLevels="1"
      MaximumDynamicDisplayLevels="3"
      SkipLinkText=""
      CssClass="s4-tn"/>
    <SharePoint:DelegateControl runat="server" ControlId="CustomXmlContentMapProvide" Id="DemoGlobalNavDelegate">
        <Template_Controls>
            <asp:SiteMapDataSource
              ShowStartingNode="False"
              SiteMapProvider="demoGlobalNavSiteMapProvider"
              id="demoGlobalNavSiteMapDataSource"
              runat="server"/>
        </Template_Controls>
    </SharePoint:DelegateControl>
                        </asp:ContentPlaceHolder>
                    </div>

<!-- End Custom Global Navigation -->

I have placed an example of this custom two tier navigation for SharePoint 2010 in the following .zip file: Download it Here

Here is how it will look:
image

Post a comment and let me know what you think. Enjoy!

Comments

hello, and thank you for your postings.

question about this menu item, in the master do you simply add all the code there and leave the master as is or remove the original code? I see in your attached example you leave the old stuff and simply inserted the code? Still new to SharePoint and learning, but looking for this type of menu system.

thanks again.
Dan said…
G'Day Erik,
Got another one for you..

Using the Issues Web Database template to cteae a helpdesk type app.. How can I got about getting our header and global Nav onto this ? or for that matter all new templates that are created ? I'm assuming I have to update a master page somewhere...
Unknown said…
How To: Create Hyperlink to Modal Pop-Up Form
Hii,

Good Info,Can u pls help me out for a Solution am also looking for making the "Add Document" to Place in the Top navigation Header Beside to Search Text Box according to my requiremnt.
Can u guide me how to make it possible and that once am clicking on the somee XX Doc Lib the same Upload functionality has to happen for "N" Number Doc Lib as per my client requirement.

I tried your Tip but it is only for a particular Lib !!!

Thanks in Advance !!!!

rgrds//Praveen
Anonymous said…
Thanks. Works fine on the root site of a site collection but as soon as you navigate down to subsites, the subsite URL automatically gets included as part of the links and so the links break. The sitemap used to work fine in 2007 but something in 2010 has changed the way it works.
Nick Kellett said…
Hi Anonymous, to fix the problem with the relative links, instead of using the SharePoint 2010 site map provider in the web.config, use the native XML one instead:
Nick Kellett said…
add name="MyNavProvider" siteMapFile="/_layouts/1033/MyNavProvider/mySiteMap.sitemap"
type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /
Unknown said…
Awesome article.THANKS

2 questions:

when you change the type to System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral,
it seems to change the css of my nav, have you guys encountered this bug?

Is it possible to store the mySiteMap.sitemap into a library (i.e sitecolletion/Documents/Forms/AllItems.aspx ?

thank you,*
W
SPDeveloper said…
Great Post...Thanks Mate
Anonymous said…
Hi,

Thanks for this tricks... But i try to do this and i ve got an error :













Do you know if we can put more than one two tier in a tier?
Many thanks
Chris
Anonymous said…
Here 's my code ....





Chris
Anonymous said…
Impossible to post my code ;-)

I just want to have 2 time "division1" in division...but i got an error
Prasad said…
Hi,
This is really awesome.
But after i modified master page with this navigation, if i try to modify any site settings(like Site columns,Site content types,Web parts,List templates,Master pages,Themes,Solutions) from browser, its giving error. I tried this by making this master page as Custom master page. but still all site settings links are giving errors.

Prasad
Joseph said…
hello,

Its a nice one.

Is it possible to make this as security trimmed menu

if so please mail me josephbtech@gmail.com
Jay said…
How do i manage security with it?
Brian Almeter said…
A two tier navigation can be acomplished with Out of the box SharePoint.

/* Styling for two tier navgiation */
div.s4-tn {
height: 50px;
}

li.dynamic {
display: inline-block;
margin: 0 3px;
}
Ray G said…
Does anyone know if this can be implemented in a Publishing Portal?

Thanks
Andrey said…
Hi Erik,
thank you for a great post, all works fine, but with one constraint: you can't have 2 exactly the same links in the menu, it crashes the whole site, I was able to avoid this issue and just created similar views with different names. but if there is something happened with my manu - it will crash the whole site. If you know how to avoid this critical issue, please adwise.
Orrin said…
I can't see my custom navigation on application pages. Could you help with it?

Thanks

Orrin
Andrey said…
Orrin,

please, ensure that you've put it to the right place on the masterpage (v4.master) - see example from post author.
Orrin said…
Hello Andrey,

Thanks for your reply. It is on the right place. I think I will go ahead and make changes on application pages. I have another question; my custom site map does not properly work on subsites. When I go to subsite, I exactly have the same top nav, but the links do not take you to the right place. For example; I click another site, it takes you to the place in current site. Could you tell me what can be the problem?

Thank You
Orrin
Andrey said…
Orin,
also on your app pages the ContentPlaceHolder wich contain CustomMenu is absent (in the example it "DemoGlobalNav").
About proper work of your custom menu on subsites - I can think only about one option: your links begin with "~/List/ListName" or "~/DocLibName", put full links, like "http://SiteName/..." instead.
Orrin said…
Andrey,

I tried to put full links. Somehow it does not work properly.

Orrin
asif said…
i have tried this and i can only see one Home tab in global navigation and all link coming under that tab... any help
Orrin said…
Hello,

I fixed the links by using "add name="MyNavProvider" siteMapFile="/_layouts/1033/MyNavProvider/mySiteMap.sitemap"
type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /" in web.config.

I understand that multi-levels do not apply on safeguarded application pages, and it can be fixed by modifying them, but how about some other pages like; sitesubs.aspx. Css works but multi-levels do not work on same app pages. How can I use at least three levels custom navigation menu on application pages?

Thanks
Vinay TS said…
Hi Orrin,

Can you please share me the master page code for this contentplaceholder??

Thanks in advance..
Anonymous said…
Hallo Eric,
thanks much for your post, it is good for me.

I have two questions:
1. How to hide original menu "Home"
2. How to hide the menu "View all Site Content", located directly below the original menu.
Both are visible in your post on picture at the end.
Thanks Karel
Gopinath said…
Hi Eric,

Thanks. It solves my problem.
Mandeep said…
Hello Eric,

When I try to implement this I get an error : Error parsing control: The SiteMapProvider 'demoGlobalNavSiteMapProvider' cannot be found.

I placed the DemoGlobalNav.sitemap file on "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033\STYLES\DEMO"

Changed the web config on my App server as you mentioned

and the master page changes copied from your v4.master.

It throws up the error. Can you help please ?

Thanks
Mandeep
Unknown said…
Hello Eric,
First of all great article really very helpful.
But I am facing some problem,i.e. whenever I navigate to site settings my navigation menu is not displayed.

Want to know reason behind it.Otherwise it works very fine.
Andrey said…
Suresh Lakum,
make sure that Default and Custom master pages both have DemoGlobalNav placegolder inside. Because Custom masterpage is used for displaying System pages, like Settings etc.

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...