Click here to Skip to main content
15,886,547 members
Articles / Web Development / ASP.NET

Customize QuickLanch Menu using Site Map Provider & Deloy it through Features

Rate me:
Please Sign up or sign in to vote.
4.67/5 (2 votes)
12 Apr 2009CPOL2 min read 41.6K   8   6
Customize QuickLanch Menu using Site Map Provider & Deloy it through Features

Introduction

This article introduce a way to built customized QuickLaunch Menu using sitemap provider & deploy it though feature.

Background

Share Point provides left navigation bar with conventional fly-out menu.Sometime the user may need to change the look and feel of left navigation menu item content.At the same time customized menu must be flexible enough to deploy it easily.

Image 1

Using the code

Steps 1. Define a new Custom XML Provider under tag named “<providers>” in the web.config

XML
<siteMap defaultProvider="CurrentNavSiteMapProvider" enabled="true">

      <providers>
      <!-- introduce a new xml provider to bind with quicklaunch menu -->
           <add name="CustomXmlContentMapProvider" siteMapFile="_app_bin/mainMenu.sitemap" 
               type="Microsoft.SharePoint.Navigation.SPXmlContentMapProvider, Microsoft.SharePoint, 
Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
      </providers>

Steps 2. Create a new .sitemap file in “\_app_bin “folder of virtual directory (i.e topMenu.sitemap)

XML
<?xml version="1.0" encoding="utf-8" ?> 
<siteMap> 
<siteMapNode title="At Work Resources" url="/"> 
<siteMapNode title="Booking Travel" url="http://moss2007/_layouts/viewlsts.aspx?BaseType=1"> 
<siteMapNode title="America" url="http://www.google1.com"/> 
<siteMapNode title="Asia/Australia" url="http://www.google2.com"/> 
<siteMapNode title="Europe" url="http://www.google3.com"/> 
</siteMapNode> 

<siteMapNode title="Branding" url="#"> 
<siteMapNode title="Brand" url="http://www.google5.com"/> 
<siteMapNode title="Branding Guidelines" url="http://www.google6.com"/> 
<siteMapNode title="Logos" url="http://www.google71.com"/> 
<siteMapNode title="Templates" url="http://www.google72.com"/> 
</siteMapNode> 

<siteMapNode title="Commonly Used Terms" url="http://www.google711.com"/> 

<siteMapNode title="Communities" url="#!"> 
<siteMapNode title="All Communities" url="www.dasdsa.com"/> 
<siteMapNode title="Communities With Web Sites" url="http://www.gdfgd.com"> 
<siteMapNode title="Women's Environment" url="http://www.erterer.com"/> 
<siteMapNode title="BizTalk Server" url="http://www.hksada.com"/> 
<siteMapNode title="Commerce Server" url="http://www.hkhk.com"/> 
<siteMapNode title="Delivery Management" url="http://www.sdffdsfds.com"/> 
<siteMapNode title="Diversity and Inclusion" url="http://www.fsafds.com"/> 
<siteMapNode title="Project Workspace" url="http://www.fsddsfsdfds.com"/> 
</siteMapNode> 
</siteMapNode> 
</siteMapNode> 
</siteMap> 

Step 3. Open your site master page and create a new <asp:Delegatecontrol /> just below the default Quick Launch Menu delegate control & bind this newly created delegate control to Quick Launch ASP Menu control

XML
<SharePoint:DelegateControl runat="server" ControlId="XmlQLNavigationDataSource"> 
<Template_Controls> 
<asp:SiteMapDataSource id="xmlQLSiteMap" ShowStartingNode="true" 
    SiteMapProvider="SPNavigationProvider" runat="server" /> 
</Template_Controls> 
</SharePoint:DelegateControl> 

<SharePoint:AspMenu id="QuickLaunchMenu" DataSourceId="xmlQLSiteMap" 
    runat="server" Orientation="Vertical" StaticDisplayLevels="2" ItemWrap="true" 
    MaximumDynamicDisplayLevels="3" StaticSubMenuIndent="0" SkipLinkText=""> 

Step 4. Once you do appropriate changes in the master page, quick launch will show all the content from the .sitemap file.

Scroll up to view final outcome of your quick launch.

Step 5.Moss 2007 empowered with Feature which has capability of deploying user action using a piece of xml files. In the real world scenario user may ask to deploy customized quick launch by feature.

Let’s built a new feature to deploy sitemap bounded quick launch. Create a new folder under “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\” & create two xml file

1 feature.xml

2.<file name>.xml

feature.xml :

XML
<?xml version="1.0" encoding="utf-8" ?> 
<Feature Id="541F5F57-C847-4e16-B59A-B31E90E6F9ED" Title="Customized Navigation" 
    Scope="Site" Hidden="False" DefaultResourceFile="core" 
    ReceiverAssembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" 
    ReceiverClass="Microsoft.SharePoint.Publishing.NavigationFeatureHandler" 
    xmlns="http://schemas.microsoft.com/sharepoint/" > 
<ElementManifests> 
<ElementManifest Location="filename.xml" /> 
</ElementManifests> 
</Feature> 

filename.xml:

XML
<!— Comments 
XmlQLNavigationDataSource: ID of newly created Delegate Control 
xmlQLSiteMap: ID of ASP Menu control 
CustomXmlContentMapProvider: custom xml provider defined in the web.config file 
--> 

<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> 
<Control Id="XmlQLNavigationDataSource" Sequence="25" 
ControlClass="System.Web.UI.WebControls.SiteMapDataSource" 
ControlAssembly="System.Web, version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
<Property Name="SiteMapProvider">CustomXmlContentMapProvider</Property> 
<Property Name="ShowStartingNode">true</Property> 
<Property Name="ID">xmlQLSiteMap</Property> 
</Control> 
<HideCustomAction Id="QuickLaunch" HideActionId="QuickLaunch" GroupId="Customization" 
    Location="Microsoft.SharePoint.SiteSettings" /> 
</Elements> 

Step 6. Once you built these two xml files under the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\<Your Folder Name>, use stsadm command to install feature & at last restart your IIS to reflect the changes in your site.

Points of Interest

While figuring out this solution, I felt Microsoft SharePoint team is always trying to make their products better to meet end user requirements, and I believe we will be able to see Microsoft's implementation on this issue in the next version.

History

I will keep updating as I dig into the SharePoint world. In fact, there are lots of issues like this. I think Microsoft may make WSS 3.0 much better if they get more time before publishing the next version.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralUnexpected Error Pin
dwarf8812-Jul-10 18:04
dwarf8812-Jul-10 18:04 
GeneralSelected item Pin
metalsandman24-Nov-09 1:28
metalsandman24-Nov-09 1:28 
GeneralIDs are wrong Pin
Member 203893213-Nov-09 0:25
Member 203893213-Nov-09 0:25 
GeneralThis feature didn't work for me. Pin
Nitin J. Jain3-Sep-09 20:42
professionalNitin J. Jain3-Sep-09 20:42 
GeneralRe: This feature didn't work for me. Pin
amish_khatri@mail.com11-Nov-09 17:41
amish_khatri@mail.com11-Nov-09 17:41 
GeneralRe: This feature didn't work for me. Pin
amish_khatri@mail.com11-Nov-09 17:41
amish_khatri@mail.com11-Nov-09 17:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.