通過使用Microsoft.SharePoint.WebControls.DelegateControl,我們可以為快速啟動導航指定一個自訂的
資料來源控制項。通過傳遞給該委拖(delegate)的控制項來為快速啟動提供資料來源。資料可以來自資料庫或代碼中。這種類型的定製化並不會改變連結的顯示方
式。
您可以通過替換又委託功能提供的資料來源來替換快速啟動中預設顯示的節點。
下面的樣本顯示了default.master中聲明的預設資料來源,其中指定ControlId的值為QuickLaunchDataSource。<SharePoint:DelegateControl runat="server"
ControlId="QuickLaunchDataSource"
Scope="Web">
<asp:SiteMapDataSource
SiteMapProvider="SPQuickLaunchProvider"
ShowStartingNode="False"
id="QuickLaunchSiteMap"
runat="server"
/>
</SharePoint:DelegateControl>
我們可以建立一個功能(feature)來覆蓋預設的委託。在\TEMPLATE\FEATURES目錄下建立一個檔案夾來指定替代資料來源。
首先建立Feature.xml檔案來引用feature所需的元素,包括資料來源使用的dll組件和其他XML檔案(NavigationSiteSettings.xml)。<Feature Id="541F5F57-C847-4e16-B59A-B31E90E6F9EA"
Title="Portal Left Navigation"
Description="Enable portal navigation for the left navigation bar."
Version="12.0.0.0"
Scope="Web"
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="NavigationSiteSettings.xml"/>
</ElementManifests>
</Feature>
下面是NavigationSiteSettings.xml,該檔案重定義了site map provider作為QuickLaunchDataSource控制項,將Sequence屬性值設為50,來替換預設的左側導航結點。
(註:Sequence值要比原先傳遞給委託的控制項的值低,才能替換原先的控制項)
<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>