Export (0) Print
Expand All

Using a Custom Data Source for Navigation

Windows SharePoint Services 3

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Through the Microsoft.SharePoint.WebControls.DelegateControl class, you can specify a custom data source control to provide nodes for Quick Launch navigation. The control that you specify through your delegate control candidate determines which provider to use as the data source for Quick Launch, which can be located in a database or in code. This type of customization changes the nodes that are displayed without modifying the way links are displayed.

You can replace the default nodes used in Quick Launch by specifying an alternate data source through a delegate control Feature. For information about delegate controls, see Delegate Control (Control Templatization).

The following example shows the default data source declaration in default.master, which specifies QuickLaunchDataSource as the ControlId value.

<SharePoint:DelegateControl runat="server"
  ControlId="QuickLaunchDataSource"
  Scope="Web">
  <asp:SiteMapDataSource
    SiteMapProvider="SPQuickLaunchProvider"
    ShowStartingNode="False"
    id="QuickLaunchSiteMap"
    runat="server"
  />
</SharePoint:DelegateControl>

You can create a Feature that overrides the default delegate control by adding a folder to the \TEMPLATE\FEATURES directory that specifies an alternate data source.

First create a Feature.xml file that specifies the strong-named assembly and class to use as the data source, and that references another XML file (in this example, called MyCustomNavigationSiteSettings.xml) that specifies the elements that form parts of the Feature.

<Feature  Id="541F5F57-C847-4e16-B59A-B31E90E6F9EA"
  Title="My Custom Left Navigation"
  Description="Enables custom navigation for the left navigation area."
  Version="12.0.0.0"
  Scope="Web"
  ReceiverAssembly="MyStrongAssemblyName, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
  ReceiverClass="MyNamespace.MyCustomNavigationHandler"
  xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="MyCustomNavigationSiteSettings.xml"/>
  </ElementManifests>
</Feature>

The following MyCustomNavigationSiteSettings.xml file redefines the site map provider to use as the QuickLaunchDataSource control, setting 50 as the Sequence attribute value, which specifies that the custom control be used instead for left navigation nodes.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Control Id="QuickLaunchDataSource" Sequence="50" 
    ControlClass="System.Web.UI.WebControls.SiteMapDataSource" 
    ControlAssembly="System.Web, version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <Property Name="SiteMapProvider">AreasAndPagesSiteMapProvider</Property>
    <Property Name="EnableViewState">true</Property>
    <Property Name="StartFromCurrentNode">true</Property>
    <Property Name="StartingNodeOffset">0</Property>
    <Property Name="ShowStartingNode">false</Property>
    <Property Name="ID">qlSiteMap</Property>
  </Control>
  <HideCustomAction
    Id="QuickLaunch"
    HideActionId="QuickLaunch"
    GroupId="Customization"
    Location="Microsoft.SharePoint.SiteSettings" />
</Elements>

For more information about creating and implementing Features in Windows SharePoint Services, see Working with Features. See ASP.NET 2.0 QuickStart Tutorial for information about creating an assembly to serve as a custom data source provider.

Show:
© 2014 Microsoft