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
Post a comment and let me know what you think. Enjoy!

28 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.
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...
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
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.
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:
add name="MyNavProvider" siteMapFile="/_layouts/1033/MyNavProvider/mySiteMap.sitemap"
type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /
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
Great Post...Thanks Mate
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
Here 's my code ....
Chris
Impossible to post my code ;-)
I just want to have 2 time "division1" in division...but i got an error
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
hello,
Its a nice one.
Is it possible to make this as security trimmed menu
if so please mail me josephbtech@gmail.com
How do i manage security with it?
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;
}
Does anyone know if this can be implemented in a Publishing Portal?
Thanks
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.
I can't see my custom navigation on application pages. Could you help with it?
Thanks
Orrin
Orrin,
please, ensure that you've put it to the right place on the masterpage (v4.master) - see example from post author.
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
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.
Andrey,
I tried to put full links. Somehow it does not work properly.
Orrin
i have tried this and i can only see one Home tab in global navigation and all link coming under that tab... any help
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
Hi Orrin,
Can you please share me the master page code for this contentplaceholder??
Thanks in advance..
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
Hi Eric,
Thanks. It solves my problem.
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
Post a Comment