PANVEGA’s Blog

DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

How to add a second SiteMapDataSource and ASPMenu into a MasterPage

Posted by PANVEGA on May 2, 2009

In a new project, I was asked to add a second QuickLaunch Navigation into a MasterPage.  The second Navigation should get a new custom CSS SiteMapProvider should start at a specific sub node.

Just go to the Sharepoint:SPNavigationManager tag search inside after SharePoint:AspMenu. You see the QuickLaunchMenu is consuming the SPNavigationProvider from the SiteMapDataSource.

However the second ASP:Menu “QuickLaunchMenuTwo” is using the SPNavigationProvider. You see how easy it is to add more SiteMapProvider to more than just one ASP:Menu in your MasterPage

<Sharepoint:SPNavigationManager
id=”QuickLaunchNavigationManager”
runat=”server”
QuickLaunchControlId=”QuickLaunchMenu”
ContainedControl=”QuickLaunch”
EnableViewState=”false”>
<div>
<SharePoint:DelegateControl runat=”server” ControlId=”QuickLaunchDataSource”>
<Template_Controls>
<asp:SiteMapDataSource SiteMapProvider=”SPNavigationProvider” ShowStartingNode=”false”
id=”QuickLaunchSiteMap” StartingNodeOffset=”0″ StartingNodeUrl=”sid:1025″ runat=”server” />
</Template_Controls>
</SharePoint:DelegateControl>

<SharePoint:AspMenu id=”QuickLaunchMenu” DataSourceId=”QuickLaunchSiteMap” runat=”server”
Orientation=”Vertical”  StaticDisplayLevels=”1″ ItemWrap=”true” MaximumDynamicDisplayLevels=”2″ StaticSubMenuIndent=”1″ SkipLinkText=””>
<LevelMenuItemStyles>
<asp:menuitemstyle CssClass=”ms-navheader” />
<asp:menuitemstyle CssClass=”ms-navitem” />
</LevelMenuItemStyles>
<LevelSubMenuStyles>
<asp:submenustyle CssClass=”ms-navSubMenu1″ />
<asp:submenustyle CssClass=”ms-navSubMenu2″ />
</LevelSubMenuStyles>
<LevelSelectedStyles>
<asp:menuitemstyle CssClass=”ms-selectednavheader” />
<asp:menuitemstyle CssClass=”ms-selectednav” />
</LevelSelectedStyles>
</SharePoint:AspMenu>
<div style=”margin-bottom:6px;margin-top:6px;”/>
<!–Second SiteMapDataSource and ASPMenu–>
<SharePoint:DelegateControl runat=”server” ControlId=”QuickLaunchDataSourceZwei”>
<Template_Controls>
<asp:SiteMapDataSource SiteMapProvider=”SPNavigationProvider” ShowStartingNode=”false”
id=”GlobalLeftNav” StartingNodeOffset=”0″ StartingNodeUrl=”sid:1002″ runat=”server” />
</Template_Controls>
</SharePoint:DelegateControl>

<SharePoint:AspMenu id=”QuickLaunchMenuTwo” DataSourceId=”GlobalLeftNav” runat=”server”
Orientation=”Vertical” StaticDisplayLevels=”2″ ItemWrap=”true” MaximumDynamicDisplayLevels=”1″ StaticSubMenuIndent=”0″ SkipLinkText=””>
<LevelMenuItemStyles>
<asp:menuitemstyle CssClass=”ms-navheader” />
<asp:menuitemstyle CssClass=”ms-navitem” />
</LevelMenuItemStyles>
<LevelSubMenuStyles>
<asp:submenustyle CssClass=”ms-navSubMenu1″ />
<asp:submenustyle CssClass=”ms-navSubMenu2″ />
</LevelSubMenuStyles>
<LevelSelectedStyles>
<asp:menuitemstyle CssClass=”ms-selectednavheader” />
<asp:menuitemstyle CssClass=”ms-selectednav” />
</LevelSelectedStyles>
</SharePoint:AspMenu>

</div>

</Sharepoint:SPNavigationManager>

Advertisements

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

 
%d bloggers like this: