Features

Features
 
 
Features相当于网站的一个插件,甚至可以把网站定制成许多插件的组合。在c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\template\features路径下,能够找到系统所有的features,每个feature都对应一个目录,每个目录下都包含一个feature.xml的文件。
Features的使用范围可以使场、Web应用程序、网站集、网站。
打开“网站操作”→“网站设置” →“修改所有网站设置”,在网站设置的页面中,单击“网站集功能”命令,能够看到有很多系统内置的功能
 
 
 
某些Feature必须要激活,否则,网站的很多功能用不了。如Office SharePoint Server标准版网站集功能、Office SharePoint Server发布基础架构、Office SharePoint Server企业版网站集功能这三个feature是必须激活的
 
 
Feature架构    
  使用VS2008创建一个类库, 创建feature.xml
<Feature
 ActivateOnDefault="True"|"FALSE"
 AlwaysForceInstall="TRUE"|"FALSE"
 AutoActivateInCentralAdmin="TRUE"|"FALSE"
 Creator="Text"
 DefaultResourceFile="Text"
 Description="Text"
 Hidden="TRUE"|"FALSE"
 ID="Text"
 ImageUrl="Text"
 ImageUrlAltText="Text"
 ReceiverAssembly="Text"
 RequireResources="TRUE"|"FALSE"
 Scope="Text"
 SolutionId="Text"
 Title="Text"
 Version="Text">
</Feature>
 
 
 
 
v其他属性可以参考WSS3.0SDK
 
在Feature.xml文件中,Feature元素定义了其本身,并指定了相关的程序集、文件、依赖等,或者支持该feature的一些属性。Feature.xml文件的结构如下:
Feature
ActivationDependencies
      ActivationDependency
 ElementManifests
        ElementFile
        ElementManifest
 Properties
         Property
 
 子元素ElementManifests包含一些文件,主要是Feature的元素清单和定义文件。ElementManifests子元素指定一个包含ElementManifest元素和ElementFile元素。
<ElementManifest Location=“Text”></ElementManifest>
Location属性:指定一个包含Feature元素定义的文件相对路径,如
<ElementManifest Location=“elements.xml”/>
 
 
添加自定义菜单
 
在网站操作按钮的下拉菜单中增加一个自定义菜单,当用户单击后,出现自定义界面,这个功能可以使用Feature来完成
1.feature.xml文件
<Feature Id="AA929AFF-4602-4d7f-A501-B80AC9A4BB52"
   Title="这是我利用feature增加的site级别的菜单"
   Description="这是我利用feature增加的site级别的菜单"
   Scope="Site"
   xmlns=" http://schemas.microsoft.com/sharepoint/">
 <ElementManifests>
  <ElementManifest Location="elements.xml"/>   
 </ElementManifests>
</Feature>
 
2.elements.xml
<Elements xmlns=" http://schemas.microsoft.com/sharepoint/">
 <CustomAction
      Id="mypage"
    GroupId="SiteActions"
    Location="Microsoft.SharePoint.StandardMenu"
    Sequence="200"
    Title="我的日常工作"
    Description="Getting up and going with inline code">
  <UrlAction Url="~/site/pages/request.aspx"/>
 </CustomAction>
</Elements>
 

3.Features的部署
使用命令行工具stsadm,编写一个批处理文件,执行即可。
echo Copying the feature...
echo.
rd /s /q "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\custaction"
mkdir "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\custaction"

copy /Y feature.xml  "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\custaction\"
copy /Y elements.xml  "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\custaction\"
echo.
echo Activating the feature...
echo.
pushd %programfiles%\common files\microsoft shared\web server extensions\12\bin
stsadm -o deactivatefeature -filename custaction\feature.xml -url http://mei:9000/
stsadm -o uninstallfeature -filename custaction\feature.xml -force

stsadm -o installfeature -filename custaction\feature.xml -force
stsadm -o activatefeature -filename custaction\feature.xml -url http://mei:9000/
pushd

 
 
v安装后,打开网站操作->网站设置->修改所有网站设置->网站集,可以看到
 
 
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值