这个菜单是用Feature部署上去的功能,先提一下Feature的作用:
微软在MOSS中利用Feature的特性,可以将Feature.xml中以特定格式描述的功能部署到MOSS中,这些功能包括工作流,菜单项,网站栏、内容类型...等等。然后可以在MOSS中配置启用或者停用这些功能,由于这个特性不需要进行代码开发,只需要配置Feature.xml和其中指定的另一个xml,方法简单可行。
Feature.xml如下:
<?xml version="1.0" encoding="utf-8" ?> 
<Feature Id="6098EC11-8128-409A-8D2C-414E93F67DD4" 
Title="add my menu" 
Description="this is a custom menu" 
Version="1.0.0.0" 
Scope="Site" 
Hidden="FALSE" 
DefaultResourceFile="customDocumentLibrary" 
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="elements.xml" /> 
</ElementManifests>
</Feature>
解释一下其中的内容,
Id是GUID类型标示的唯一值,可以由VS自带的GUID Generator来生成,
Tiltle是功能标题,Version是版本号,Description:对description的描述,
Scope:其值可以是Web或Site,它指明了这个Feature是应用于整个的Site Collection还是仅仅用于单独的一个子站点。
Hidden:值可以是True或False.该设置指定了这个Feature是否在Site Feature页面上显示。DefaultResourceFile:资源文件名字,Feature依赖它提供其它附加的配置信息。
AlwaysForceInstall:这个属性设置为true 可以在重复安装这个feature中自动覆盖原来安装的那个相同的feature.
Feature.xml文件中的<ElementManifests>元素,这个元素包含了另一个XML文件的位置,而这个文件包含的<Elemnets>的内容是Feature要实现的。
<ElementManifest>元素指明了要使用一个名为ProvisionedFiles.xml的文件,以下是该文件的<Elements>元素内容。
下面是Feature.xml中指定的elements.xml内容:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- create command link site setting page -->
<!--第一个 -->
<CustomAction Id="UserInterfaceLightUp.SiteActionsToolbar"
GroupId="ActionsMenu"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1000"
ImageUrl="~sitecollection/eip/bbs/imgages/11.PNG"
Title="匿名开启/关闭的设置">
<UrlAction Url="~sitecollection/eip/bbs/aspx/BBS_Cryptonym.aspx"/>
</CustomAction>
<!--第二个 -->
<CustomAction Id="UserInterfaceLightUp.SiteActionsToolbar1"
GroupId="SiteActions"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1000"
ImageUrl="~sitecollection/eip/bbs/imgages/11.PNG"
Title="匿名开启/关闭的设置">
<UrlAction Url="~sitecollection/eip/bbs/aspx/BBS_Cryptonym.aspx"/>
</CustomAction>
<!--第三个 -->
<CustomAction Id="UserInterfaceLightUp.SiteActionsToolbar3"
GroupId="Customization"
Location="Microsoft.SharePoint.SiteSettings"
Sequence="306"
Title="匿名开启/关闭的设置">
<UrlAction Url="~sitecollection/eip/bbs/aspx/BBS_Cryptonym.aspx"/>
</CustomAction>
<!--第四个 -->
<CustomAction Id="UserInterfaceLightUp.SiteActionsToolbar"
GroupId="NewMenu"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1000"
ImageUrl="~sitecollection/eip/bbs/imgages/11.PNG"
Title="匿名开启/关闭的设置">
<UrlAction Url="~sitecollection/eip/bbs/aspx/BBS_Cryptonym.aspx"/>
</CustomAction>
<!—第五个 -->
<CustomAction Id="ECBItemToolbar"

RegistrationType="List"
RegistrationId="101"
Location="EditControlBlock"
Sequence="106"
Title="匿名开启/关闭的设置">
<UrlAction Url="~sitecollection/eip/bbs/aspx/BBS_Cryptonym.aspx"/>
</CustomAction>
</Elements>

其中第一个CustomAction在Action(操作)下拉菜单下创建了一个自定义菜单项.
第二个CustomAction在页面的Site Action(网站操作)菜单下增加了一个用户自定义菜单项.
第三个CustomAction在Site Setting(网站设置)页面中的LOOK AND FEEL标题下创建了一个自定义链接.
第四个CustomAction在文档库的New(新建)下拉菜单下创建了一个自定义菜单项.
第五个CustomAction是在文档库的每个列表项的菜单上增加一个菜单项
RegistrationId: 定义于哪种类型(参照RegistrationId列表)
Location和groupid两个属性分别指定该feature是定义了哪两个菜单.
Sequence属性指定新增加的菜单项在这个菜单中的排序,设置的大一点该菜单项排列就靠后.
Title 和 Description分别是该菜单项的标题和描述.
UrlAction属性指定了该菜单项的连接到的页面,当然了,这个demo连接到的是我们在第一步中建立那个页面.这里有一个相对路径的问题,~site 表示站点的主目录, ~sitecollection 表示站点集的主目录.因为我的demo是做在一个站点集下面的,所以采用~sitecollection后面是连接文件的相对路径..
再做俩个批处理文件来部署和卸载这个Feature
部署批处理文件InstallFeature.bat
@rem======================================================================
@rem
@rem InstallFeature.bat
@rem
@rem======================================================================
@echo off
setlocal
pushd .
goto InstallFeature
@rem----------------------------------------------------------------------
@rem InstallFeature
@rem----------------------------------------------------------------------
:InstallFeature
set SPAdminTool=%CommonProgramFiles%\Microsoft Shared\web server extensions\12\BIN\stsadm.exe
set TargetUrl=http://huijianming
set FeaturePath=menu\Feature.xml
echo InstallFeature %FeaturePath%
"%SPAdminTool%" -o installfeature -filename %FeaturePath% -force
echo Activating feature %FeaturePath%
"%SPAdminTool%" -o activatefeature -filename %FeaturePath% -url %TargetUrl% -force
echo iisreset
iisreset
卸载批处理文件UnInstallFeature.bat
@rem======================================================================
@rem
@rem UnInstallFeature.bat
@rem
@rem======================================================================
@echo off
setlocal
pushd .
goto UnInstallFeature
@rem----------------------------------------------------------------------
@rem UnInstallFeature
@rem----------------------------------------------------------------------
:UnInstallFeature
set SPAdminTool=%CommonProgramFiles%\Microsoft Shared\web server extensions\12\BIN\stsadm.exe
set TargetUrl=http://eip.brc.com.cn:81/bbs
set FeaturePath=BBSMySiteAction1\Feature.xml
echo InstallFeature %FeaturePath%
"%SPAdminTool%" -o uninstallfeature -filename %FeaturePath% -force
echo iisreset
iisreset
将以上的两个XML放到Menu的文件夹中,然后将文件夹拷贝到C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES
RegistrationId列表:
InvalidType = -1
GenericList = 100 //列表
DocumentLibrary = 101 //文档库
Survey = 102
Links = 103
Announcements = 104
Contacts = 105
Events = 106
Tasks = 107
DiscussionBoard = 108 //讨论板
PictureLibrary = 109
DataSources = 110
WebTemplateCatalog = 111
UserInformation = 112
WebPartCatalog = 113
ListTemplateCatalog = 114
XMLForm = 115
MasterPageCatalog = 116
NoCodeWorkflows = 117
WorkflowProcess = 118
WebPageLibrary = 119
CustomGrid = 120
DataConnectionLibrary = 130
WorkflowHistory = 140
GanttTasks = 150
Meetings = 200
Agenda = 201
MeetingUser = 202
Decision = 204
MeetingObjective = 207
TextBox = 210
ThingsToBring = 211
HomePageLibrary = 212
Posts = 301
Comments = 302
Categories = 303
Pages = 850 (thanks to Anders Jacobsen for this one)
IssueTracking = 1100
AdminTasks = 1200
浙公网安备 33010602011771号