65.9K
CodeProject 正在变化。 阅读更多。
Home

使用站点地图提供程序自定义 QuickLanch 菜单并将其部署到功能中

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.67/5 (2投票s)

2009年4月11日

CPOL

2分钟阅读

viewsIcon

43231

使用站点地图提供程序自定义 QuickLanch 菜单并将其部署到功能中

引言

本文介绍了一种使用站点地图提供程序构建自定义 QuickLaunch 菜单并通过功能部署的方法。

背景

SharePoint 提供带有传统飞出菜单的左侧导航栏。有时用户可能需要更改左侧导航菜单项的内容外观。同时,自定义菜单必须足够灵活,以便轻松部署。

使用代码

步骤 1. 在 web.config 文件中的名为“<providers>”的标签下定义一个新的自定义 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>

步骤 2. 在虚拟目录的“\_app\_bin”文件夹中创建一个新的 .sitemap 文件(例如 topMenu.sitemap)。

<?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> 

步骤 3. 打开站点母版页,在默认 Quick Launch 菜单委托控件下方创建一个新的 <asp:Delegatecontrol />,并将新创建的委托控件绑定到 Quick Launch ASP 菜单控件。

<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=""> 

步骤 4. 完成母版页的相应更改后,Quick Launch 将显示 .sitemap 文件中的所有内容。

向上滚动以查看 Quick Launch 的最终效果。

步骤 5. Moss 2007 具有功能,能够使用 XML 文件部署用户操作。在实际场景中,用户可能会要求通过功能部署自定义 Quick Launch。

让我们构建一个新的功能来部署站点地图绑定的 Quick Launch。在“C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\”下创建一个新文件夹,并创建两个 XML 文件。

1 feature.xml

2.<file name>.xml

feature.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

<!— 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> 

步骤 6. 在 C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\<Your Folder Name> 下构建这两个 XML 文件后,使用 stsadm 命令安装功能,最后重启 IIS 以反映站点中的更改。

关注点

在研究此解决方案时,我感到 Microsoft SharePoint 团队一直在努力改进他们的产品,以满足最终用户的需求,我相信我们将在下一个版本中看到 Microsoft 对此问题的实施。

历史

我会继续更新,因为我深入研究 SharePoint 世界。事实上,像这样的大量问题。我认为如果他们在发布下一个版本之前有更多时间,Microsoft 可以使 WSS 3.0 更好。

© . All rights reserved.