Main Menu
Home
News
Links
Contact Us
Search
Steve's Blog
Erica's Blog
Pictures
Downloads
Guitar Music
SharePoint
Who's Online
We have 16 guests online


Using Features to enable Drop-Down Menus in Team Sites PDF Print E-mail
Written by Steve Lineberry   
Saturday, 25 August 2007

I recently was trying to enable the top nav bar to be a drop down menu of all of the sub sites. I found this article http://sharingpoint.blogspot.com/2007/02/wss-v3-drop-down-menus-in-team-sites.html which told me everything I needed to know. Instead of modifying the default.master and the TopNavBar.ascx (for the application.master) to change the SPNavigationProvider to SPSiteMapProvider, I decided I wanted each teamsite to have the option and I'm reluctant from changing SharePoint system files (see http://www.graphicalwonder.com/?p=532), so I put this part into a feature. Here's my code below:

The first file is Feature.xml

<Feature  Id="22b94164-5348-11dc-8314-0800200c9a66"
          Title="All Sites in Site Collection Navigation"
          Description="Enable all sites in the site collection top navigation bar."
          Version="12.0.0.0"
          Scope="Web"
          Hidden="false"
    DefaultResourceFile="core"
    xmlns="http://schemas.microsoft.com/sharepoint/">
    <ElementManifests>
        <ElementManifest Location="NavigationSiteSettings.xml"/>
    </ElementManifests>
</Feature>

The second file is NavigationSiteSettings.xml

<Elements
    xmlns="http://schemas.microsoft.com/sharepoint/">
    <!-- Top Nav -->
 <Control 
        Sequence="25"
        Id="TopNavigationDataSource"
  ControlClass="System.Web.UI.WebControls.SiteMapDataSource"
  ControlAssembly="System.Web, version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
        <Property Name="ID">topSiteMap</Property>        
        <Property Name="SiteMapProvider">SPSiteMapProvider</Property>
        <Property Name="ShowStartingNode">true</Property>
    </Control>
    <HideCustomAction
        Id="TopNav"
        HideActionId="TopNav"
        GroupId="Customization"
        Location="Microsoft.SharePoint.SiteSettings" />
</Elements>

I still needed to modify the default.master and TopNavBar.ascx (you don't need to edit the TopNavBar.ascx if you are implementing my Using your SharePoint site Master Page on all application pages) so that more than one level is shown. I haven't figured out a way around that part yet. Does anyone else know a way to override the SharePoint.AspMenu control?

------------------------------------------------------------------------------------------------------------
Update (09/21/07): I have since found out that apparently the SPSiteMapProvider relies on the user having permissions to view the top-level site in the site collection. If the user does not have access to this top-level site, then they will be prompted for authentication and won't be able to access the site. Using Reflector I was able to find the code where they are finding the top-level site without checking for permissions first.

I ended up having to write my own SiteMapProvider that did the correct security checking and trimming while still allowing access to the site.

On a side note, while I was looking into this issue, I also noticed that the Global Breadcrumbs (which also uses the SPSiteMapProvider) doesn't do security trimming. So I wrote a SiteMapProvider for the Global Breadcrumbs as well that did security trimming. There doesn't seem to be a delegate control for the Global Breadcrumbs like there is for the top nav so I couldn't write a feature to override the default. So I decided to just change my default.master and in combination with Using your SharePoint site Master Page on all application pages all pages will use my custom SiteMapProvider for the Global Breadcrumbs.

------------------------------------------------------------------------------------------------------------
Update (05/19/08): Some people have asked for the source code of my custom site map providers. You can download my latest files below:

AllSitesInSiteCollectionNavTrimmed.cs

AllSitesBreadcrumbsTrimmed.cs

FYI, this may not be the most efficient code and I have noticed some caching issues with it sometimes. Other than that it seems to work great.

Comments
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it on 2007-12-13 05:04:44
:) Hey Even i am also facing the same problem, how to hide action menu drop down actions
Written by marioosh on 2009-03-24 08:17:13
i still have a problem with instaling your AllSitesInSiteCollectionNavTrimmed.cs, how to deploy and install ?
Written by Steve on 2009-03-24 09:17:58
Well, I compiled it into a dll, and then in the web.config added it to the list of sitemap providers. Then in NavigationSiteSettings.xml (above) I changed the sitemapprovider from SPSiteMapProvider to the name I gave mine in the web.config. 
 
You might just be able to copy the cs file into the app_code folder instead of having to compile it into a dll. 
 
FYI, I have rewritten both of these sitemapproviders here because of performance issues. I am currently unable to distribute them because it uses some other classes I've made specifically for work.
Quick Question
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it on 2009-06-19 08:42:37
Hi there,  
 
A few questions for you, I compiled the code and installed the .dll to the GAC, I then updated my web.config with the following line: 
 
Code:

 
 
To test, I created a sub site and changed the default.master as follows: 
 
Code:
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
However when I applied this to a single page it caused the entire collection to display "An unknown error has occured" when connecting to the site. 
 
So my question is what am I doing wrong? Would appreciate any help you can offer.
drop down menu
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it on 2009-07-08 14:15:15
Hello, 
I’ve done the modification in master page require in: 
http://sharingpoint.blogspot.com/2007/02/wss-v3-drop-down-menus-in-team-sites.html 
in order to get drop down menu in top navigation link and now the tabs are sorted in alphabetical order. It seems to be a known problem linked with the change of: 
SiteMapProvider="SPNavigationProvider" with SiteMapProvider="SPSiteMapProvider" 
Did anybody fix this issue? 
Thank you 
Grig
Written by Vik on 2010-07-28 08:54:55
Hi, 
 
I have created the new sitemapprovider in my project (AllSitesInSiteCollectionNavTrimmed.cs) and added it to the web.config. I then amended my master page to use this but when navigating to site I recieve the following error: 
 
System.InvalidCastException: Unable to cast object of type 'System.Web.SiteMapNode' to type 'Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode' 
 
Can anyone help with this please? 


Write Comment
  • Please keep the topic of messages relevant to the subject of the article.
  • Personal verbal attacks will be deleted.
  • Please don't use comments to plug your web site.. Such material will be removed.
Name:
E-mail
Homepage
Title:
BBCode:Web AddressEmail AddressBold TextItalic TextUnderlined TextQuoteCodeOpen ListList ItemClose List
Comment:



Code:* Code

Powered by AkoComment!

Last Updated ( Saturday, 14 November 2009 )
 
< Prev   Next >
Latest Blogs
   Home arrow Steve's Blog arrow Using Features to enable Drop-Down Menus in Team Sites