Posted by: Jeremy Benisek (CyberAxe) Don't Panic Business Technologies | January 22, 2011

Easy and Simple SharePoint 2010 Dropdown Navigation bar that works no scripts, no web.config, works on hosted providers

http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010general/thread/a32b03d6-44c9-4c6d-a11d-8dc15c583737?prof=required

I tried the above and it didn’t work, I’m on a hosted sharepoint 2010 at sherweb.com

The above answer didn’t work for me and I got a nasty error about type IHierarchicalDataSource and missing control ID however after hours of trial and error and going back to my SharePoint 2007 drop down menu hack I found a easy solution with no need for web.config editing or any of this other script crap I keep hearing. Since I can’t access my web.config file anyways and a script won’t be accepted by my host.

Here is my code in a custom Master.page I used SharePoint Designer to set the DataSourceID=SiteMapDataSource1 – in the GUI click the TopMenuNav bar click the top-right > arrow and then “New Data Source” use the default name.

Code should look like this. I also changed the SPSiteMapProvider under
SiteMapProvider in both ID= under AspMenu and SiteMapProvider under
aspSiteMapDataSource

<SharePoint:AspMenu
	  ID="SPSiteMapProvider"
	  Runat="server"
	  EnableViewState="false"
	  DataSourceID="SiteMapDataSource1"
	  UseSimpleRendering="true"
	  UseSeparateCss="false"
	  Orientation="Horizontal"
	  StaticDisplayLevels="2"
	  MaximumDynamicDisplayLevels="4"
	  SkipLinkText=""
	  CssClass="s4-tn"/>
	<asp:SiteMapDataSource runat="server" ID="SiteMapDataSource1" />
	<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate">
		<Template_Controls>
			<asp:SiteMapDataSource
			  ShowStartingNode="True"
			  SiteMapProvider="SPSiteMapProvider"
			  id="topSiteMap"
			  runat="server"
			  StartingNodeUrl="sid:1002"/>
		</Template_Controls>
	</SharePoint:DelegateControl>

This is a GOD SEND! I'll be hosting a site with 50 to 100 project sites and without the drop down menu it's hell!
Thank You for your help and I hope this helps everyone else. Please suggest to Microsoft they add this feature by default.

I will also post this at https://jbenisek.wordpress.com  for comments and any updates.
FYI Sherweb.com hosts SharePoint 2010 with unlimited users/sites starting at >$20/month all based on storage space. I LOVE YOU SHERWEB!

----------------------

Due to questions I hope this will help, I'm posting my masterpage

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

Edit your current Masterpage with the needed changes above, then I save as Custom.v401.master, it’s CRTICAL you copy and set this as your Default Masterpage in each site you want to have a drop down menu. You do this in SharePoint Designer 2010.

I’ve built this masterpage into my templates so I don’t have to do this except on already created sites.

 

 

Advertisements

Responses

  1. This is great – thanks! I think I see that instead of using the top link bar datasource, tis solution uses the site map. (Right?) Have you found any way to modify the link bar when using this solution? Since the site map is pretty fixed, I’m assuming the nav bar is fixed also?

    • I haven’t tried, this solution fits my needs almost 100%.

      There is only one downside so far, other than the managed links you’re talking about, when browsing core pages, like security or site settings you loss the bar all together. I kind of like this because it forces you to use the local crumb link bar at the top. This keeps people from changing to another site while they are doing site setting or security based stuff. I would assume you could edit the core pages and change their master.page just like we did here, however I’ve not tried it.

      In wss2 and wss3 we tried to edit the bars links and I wasn’t able to, however I only have basic trainning and skills in asp. I’m sure there might be a solution please post a link if you find one.

      I’ve used a basic solution of building my site tree to match the drop down menu I would like to have. You could edit your master page and # out the links on pages you only wanted as a place holder for sub sites but I’ve been very happy with this solution as is and often can’t figure out why Microsoft doesn’t support the demands of their customers. They use drop down menu’s on their sites and in many other areas of sharepoint but refuse to build complete products that show maturety.

      I would assume you could edit the core pages and change their master.page just like we did here, however I’ve not tried it.

      • I have found that I can man-handle the nav bar by adding special characters to the front of the site names. The Site Map lists sites by name, so by adding a “Thin space” or “Hair space” to the front of the name, I could change it’s location on the list. I got the spaces/characters by using the Character Map and looking for non-printing or non-displaying characters. It’s not elegant, but it works. I have yet to try and hide a site from the list. Thanks again for your work.

  2. I seem to haver this installed successfully … at least subsites are automatically showing as tabs on the top horizontal menu. Maybe I’m missing something. Is this supposed to show a flyout/dropdown when a user hovers over a tab? If so, what determines the content of the flyout/dropdown?

    • The ID map source controls the drop down then the number of subsites you want to show. Out of the box these changes in my post will do what you want, if you’d like to change how it does it change the numbers forward and back, also change:
      ShowStartingNode=”True” test this one if you only want one Menu then drop down to subsite.

      My setup is set to drop down the third site. So base site (no drop down), sub site (no drop down), subsite of sub (drop down)
      You can modify this by changing
      StaticDisplayLevels=”2″
      MaximumDynamicDisplayLevels=”4″

      Try these two changes

  3. It appears to be working, but it may not be what I want. The perfect setup for me is a second-level site with a several content pages showing nothing in the content area other than an iframe.

    For this solution I have to set up a separate site for each menu item/page. That’s OK although it’s a lot of extra work initially.

    I don’t like the fact that the breadcrumbs are useless for navigating through the sites since the breadcrumbs show the current site as the starting point; in my application the user thinks of it all as one site and is going to be confused by the lack of useful breadcrumbs.

    And the highlight on the top menu bar is often confusingly wrong. Start with http://sharepointserver/sites/Test. Then I create http://sharepointserver/sites/Test/A, /B, and /C. Then http://sharepointserver/sites/Test/A/A1, A2, and A3.

    At http://sharepointserver/sites/Test/A, the Test menu item is highlighted and the A menu item is not. Same for http://sharepointserver/sites/Test/A/A1 and http://sharepointserver/sites/Test/A/A3. But at http://sharepointserver/sites/Test/A/A2 the A menu item is highlighted. I can’t figure out why, they all have identical master pages and custom CSS (I had to copy and paste the master pages in SharePoint Designer since I’m using SharePoint Foundation. I do have the push-master-to-all-sites add-on but I don’t what to push the very top-level master to these subsites).

    • I agree it’s not perfect but it works better than the basic menu system. I run 50-100 sites at a time and the basic static menu system sucks!
      I do not think the highlight site issue is fixable because we’re jury rigging the setup. The Database that we are using to do the drop down nav doesn’t track current sites as far as I’ve seen. I like no highlight because HOME is always bolded like thats part of the CCS. You might be able to change this in CCS/MASTERPAGE so no current shows up. You might be able to do this in the masterpage of each site but I’ve not sure. It would be alot of work.

      Breadcrumbs – I’ve not tried this but I see NO reason why you could ajust the show root site link… for Breadcrumb, I’ve not seen this option but assume it’s there because it uses the same system the drop down nav does.

      Also both drop down and breadcrumb don’t show up on SYSTEM pages.

      If I come up with something I’ll let you know.

  4. Tried this. Didn’t work for me. The change is similar to one in WSS 3.0 which works. It appears as though this does not work for SharePoint Foundation. It was an invaluable feature in WSS which now appears to be eliminated.

    • Something has to be wrong in the code then. Did you change the masterpage and everything? We’ve used this on many cloud hosted sharepoint foundation sites. Don’t give up on this because it does work.

      • I am not sure what is wrong but this method is refusing to work on Sharepoint 2010 foundation. I have tried every possible way. I am absolutely stumped, wish you can find something different for the Sharepoint foundation.
        Thank you

      • Edit your current Masterpage with the needed changes above, then I save as Custom.v401.master, it’s CRTICAL you copy and set this as your Default Masterpage in each site you want to have a drop down menu. You do this in SharePoint Designer 2010.

        I’ve built this masterpage into my templates so I don’t have to do this except on already created sites.

  5. Great Post, Very Usefull.
    I have a question. I created a dropdown menu by following this post, but only 20 submenu appear in the menu on my site and in my site there are 22 subsites.
    Any ideas?
    Please help me.

    • In wssv3 I had a ton of sites maybe 40 to 60 at the sametime. However, in wssv4/2010 I’ve only tried maybe most of 10. You could just do one more layer if you had to. The problem I’ve found to more than the width of your screen is it doesn’t scroll very well. Our staff are the only people that see all of the sites our clients only see the 1 or 2 sites they have access to.

      I don’t know that people understand how the layer works on this menu by some of the comments. So I want to make sure and state I’m not running my sites off the first base page.
      I use the menu like this || Project Home | Staff intranet | Projects ||
      Which would look like
      Project Home (Root)
      -Staff Intranet (Subsite Layer 1)
      —Office (Subsite Layer 2)
      —IT (Subsite Layer 2)
      —Management (Subsite Layer 2)
      -Projects (Subsite Layer 1)
      —0001 | Park Walk Way (Subsite Layer 2)
      —0002 | Big Building (Subsite Layer 2)
      —0000 | Test and Demo Sites (Subsite Layer 2)
      ——-Beta (Subsite Layer 3)
      ————xxxx | Template v0001 (Subsite Layer 4)
      ————xxxx | Template v0002 (Subsite Layer 4)
      and so on

      The reason I use time to write this is I’m not sure what the rules or effects of using all your sites on the root site vs using the sites on a layer 1, layer 2…site. Please reply with the layout your using if it’s different than this.

  6. whoah this blog is excellent i love reading your posts. Keep up the good work! You know, lots of people are searching around for this info, you can aid them greatly.

  7. Interesting Blog, Dude! even though this was not what i was looking for (I am on thelookout for guides on how to market products for my hand-made carpets )… I certainly plan on visiting again!..By the way ,if anybody can suggest any links it would be great ! thanks a lot and i will bookmark your article : Keywords define a company | The MarketReacher… I think this is a real great post.Really thank you! Great.

  8. Is there a way to show pages within the site on the top navigation bar ? I am using sharepoint foundation 2010.

    • This is a great question and I’m not sure I haven’t tried it. If you find something please let us know, I will keep my eyes out.

  9. Excellent read, I just passed this onto a colleague who was doing a little research on that. And he actually bought me lunch because I found it for him smile So let me rephrase that: Thanks for lunch!

  10. Wow, just wanted to thank you for this wonderful solution which has taken me up to 2 months to find (as well as buying a Sharepoint Branding book – i wont mention names) which offered a solution but failed to work. MS should realise that without having this function as standard they are failing to understand usability and navigation. I’ve got to deploy a site that has about 25 sub sites and not having proper drop downs has been a huge stumbling block. I’m going to read on customising it for other levels and I will add it on to other master pages as you have recommended. By the way, a companies offering this solution for 100’s of pounds – not too sure if you were looking to wrap this up in an web part for sale – but nevertheless I can only say THANK YOU and well done.

  11. This solution breaks the ordering in the Top navigation bar, just so you guys know.

    • Changes to ABC I believe

  12. So I’m new to web design, but this was such an easy solution that I kept looking for weeks thinking I was missing something! Thank you so much. Do you have any good references for changing the look and feel of the fly out menu’s?

  13. Just testing the solution and I have found that irrespective of which page is being displayed, only the ‘Home’ page is highlighted in the menu rather than the current page. Any suggestions what I might of broken? Otherwise the menu is working perfectly.

    • I don’t think you’ve done anything. Mine reacts the same way. I’m not sure why, in my solution I use them directly as drop downs so it doesn’t really matter. I’m not sure if it would be fixable.

      I think I’d start with the css but I’m worried the data source doesn’t have a current page options or it isn’t being set so the css can change the style. I’m no expert at this however.

  14. Hello,

    I have used the above code and it work very well however I have one issue.

    I have a user that I only want them to access a sub site and nothing else. However I get all the permission and use the drop down code, but it does not work. If I give them access to the home page (root), it works.

    Does the code above need some resource from the root/home site?

    • It does seem the root must be used however there is an options I’ve been thinking about. When you setup a website there is an option to use the Root sites menu on this new site. I normally check yes even though it doesn’t effect anything given we have this custom drop down setup.

      However, I was thinking it might be that this option is causing the security lockout for drop down.

      Also I’m working on allowing anonymous access over a SSL site and haven’t been able to do it without allowing access to one of the root sites.
      I’m not sure a solution at this point but I’ll post one if I can.

      It might come down to a custom master page without drop down for that user group.

      I’m working on this today for my anonymous site and will post my thought once it’s done.

    • Ok so I’ve played with this and come up with a solution.
      You must have the ROOT be anonymous access.

      Change all subsites to non-inherits and verify their security.
      Change Root (base level) site to Anonymous Access and make sure to verify the Root site doesn’t have any security sensitive information.
      I made my Root site more like a Company Public Website (kind of) then change the subsite you want to be anonymous (or inherit from root)
      You can check out my site at https://sharepoint.blytheprojects.com
      Notice you can see Root and Public but not Intranet, Projects, Transfers which are there just not setup for Anonymous.

      This solution setup was also requried in WSSv3 for FBA to work.

      If you have information on the Root site then you can move it to a subsite and secure it there.

      Here is an example:
      Project Home (Root) [Anonymous]
      -Staff Intranet (Subsite Layer 1) [Not-Inheriting]
      -—Office (Subsite Layer 2)
      -—IT (Subsite Layer 2)
      —Management (Subsite Layer 2)
      -Projects (Subsite Layer 1) [Not-Inheriting]
      -—0001 | Park Walk Way (Subsite Layer 2) [Not-Inheriting]
      -—0002 | Big Building (Subsite Layer 2) [Not-Inheriting]
      -—0000 | Test and Demo Sites (Subsite Layer 2) [Not-Inheriting]
      -——-Beta (Subsite Layer 3) [Not-Inheriting]
      -————xxxx | Template v0001 (Subsite Layer 4) [Not-Inheriting]
      -————xxxx | Template v0002 (Subsite Layer 4) [Not-Inheriting]
      -Public (Subsite Layer 1)[Anonymous] [Inheriting]
      –1225 | Big Building Public Access [Anonymous] [Inheriting]

  15. I was more than happy to uncover this great site. I need to to thank you
    for your time for this wonderful read!! I definitely liked every part of it and i also have you saved to fav to look at new things on your blog.

  16. My brother recommended I might like this blog. He was totally right.

    This post actually made my day. You cann’t imagine simply how much time I had spent for this info! Thanks!

  17. whoah this weblog is fantastic i love reading your articles.

    Stay up the great work! You already know, many individuals are looking round
    for this information, you can aid them greatly.

  18. This and other related blogs causes the home tab to be replaced with the page title. How can this issue be resolved

    • yes I think if you change the numbers in the code. There is also a flag I think, it’s been years since I’ve looked at this code but change the sub-menu/menu numbers around and I think you’ll get a home. I might be called root.

  19. I have try several combinations. I think this is a SharePoint 2010 Foundation problem. It is a SharePoint foundation issue.

    • Try changing the below – StaticDisplay to =”0″ and Showstartingnode=”true”

      <SharePoint:AspMenu
      ID=”demoGlobalNavAspMenu”
      Runat=”server”
      EnableViewState=”false”
      DataSourceID=”demoGlobalNavSiteMapDataSource”
      AccessKey=””
      UseSimpleRendering=”true”
      UseSeparateCss=”false”
      Orientation=”Horizontal”
      StaticDisplayLevels=”0″
      MaximumDynamicDisplayLevels=”3″
      SkipLinkText=”"
      CssClass=”s4-tn”/>

      <asp:SiteMapDataSource
      ShowStartingNode=”True”
      SiteMapProvider=”demoGlobalNavSiteMapProvider”
      id=”demoGlobalNavSiteMapDataSource”
      runat=”server”/>

  20. After looking at a number of the blog posts on your blog, I honestly like your technique of writing a blog. I saved it to my bookmark webpage list and will be checking back soon. Take a look at my web site as well and let me know how you feel.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: