Feature之使用Feature定义站点中的菜单项
原文链接:http://tech.it168.com/d/2008-05-26/200805260910184.shtml
【IT168技术文档】
包括其中第一个CustomAction在“网站设置”页面中的“外观”标题下创建了一个自定义链接.第二个CustomAction在页面的“网站操作”菜单下增加了一个用户自定义菜单项.第三个CustomAction在文档库的“新建”下拉菜单下创建了一个自定义菜单项.第四个CustomAction在文档库的“操作”下拉菜单下创建了一个自定义菜单项。
步骤:
创建一个Feature.xml文件
在Features目录下创建一个目录例如MyMenu,在其中创建一个Feature.xml文件,文件内容如下:
<?xml version="1.0" encoding="utf-8" ?> <!-- _lcid="1033" _version="12.0.4017" _dal="1" --> <!-- _LocalBinding --> <Feature Id="6098EC11-8128-409A-8D2C-414E93F67DD4" Title="$Resources:GasMenu,MenuTitle;" Description="$Resources:GasMenu,MenuDescription;" Version="12.0.0.0" Scope="Web" Hidden="FALSE" DefaultResourceFile="customDocumentLibrary" xmlns="http://schemas.microsoft.com/sharepoint/"> <ElementManifests> <ElementManifest Location="LightUp.xml" /> </ElementManifests> </Feature>
在C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Resources文件夹中新建GasMenu.zh-CN.resx文件,输入以下内容
<?xml version="1.0" encoding="utf-8"?> <!-- _lcid="2052" _version="12.0.4518.1016" _dal="1" --> <!-- _LocalBinding --> <root> <Data Name="MenuTitle"> <Value>天然气菜单项</Value> </Data> <Data Name="MenuDescription"> <Value>添加了四个菜单项,分别为在“网站设置”页面中的“外观”标题下创建了一个自定义链接、在页面的“网站操作”菜单下增加了一个用户自定义菜单项、在文档库的“新建”下拉菜单下创建了一个自定义菜单项和在文档库的“操作”下拉菜单下创建了一个自定义菜单项。< /Value> </Data> </root>
创建Feature的描述文件LightUp.xml
文档的内容如下:
<?xml version="1.0" encoding="utf-8" ?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <!-- create command link site setting page --> <CustomAction Id="SiteSettings" GroupId="Customization" Location="Microsoft.SharePoint.SiteSettings" Sequence="106" Title="Custom Site Setting Command"> <UrlAction Url=""/> </CustomAction> <!-- Add command to site action dropdow --> <CustomAction Id="SiteActionsToolbar" GroupId="SiteActions" Location="Microsoft.SharePoint.StandardMenu" Sequence="1000" Title="Custom Action" Description="custom site action" ImageUrl="/_layouts/images/ACG16.GIF"> <UrlAction Url=""/> </CustomAction> <!-- Document Library Toolbar New Menu DropDown --> <CustomAction Id="DocLibNewToolbar" RegistrationType="List" RegistrationId="101" GroupId="NewMenu" Rights="ManagePermissions" Location="Microsoft.SharePoint.StandardMenu" Sequence="1000" Title="Custom New Command" Description="custom new command " ImageUrl="/_layouts/images/ACG16.GIF"> <UrlAction Url=""/> </CustomAction> <!-- Document library Toolbar Actions Menu Dropdown --> <CustomAction Id="DocLibActionsToolbar" RegistrationType="List" RegistrationId="101" GroupId="ActionsMenu" Rights="ManagePermissions" Location="Microsoft.SharePoint.StandardMenu" Sequence="1000" Title="Command on Document Library" Description=" command on document library" ImageUrl="/_layouts/images/ACG16.GIF"> <UrlAction Url=""/> </CustomAction> </Elements>
4、重启IIS(iisreset)
5、在SharePoint服务器上运行CMD.exe,
输入命令切换目录:cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
安装Feature输入命令:stsadm -o installfeature -filename MyMenu
激活Feature输入命令:stsadm -o activatefeature -filename MyMenu\feature.xml -url http://portal:8000/
This posting is provided "AS IS" with no warranties, and confers no rights.
浙公网安备 33010602011771号