WSS3SDK之:如何创建一个简单的Feature

本例将带领您一步一步创建一个自定义操作Feature,来在SharePoint网站范围内添加一个按钮到编辑通知窗体的工具栏。

步骤

  1. 在in Local_Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES创建一个SimpleFormToolbarButton 文件夹。
    注意
    当 您通过Windows资源管理器(右击一个文件夹,点新建,然后点文件夹)在Features目录中创建一个文件夹时,新文件夹不会继承权限。如果您将 Feature部署到该文件夹中,则在一些WSS页面中(比如网站设置或列表视图)将引发异常。您可以右键点击该新文件夹,点属性,点安全,然后点高级, 在全县标签中,选择允许父项的继承权限传播到该项及其子项。包括那些在此明确定义的项目,点确定。这样就可以修正该问题。您也可以通过命令行用md命令新 建文件夹,也能解决问题。

    在该文件夹中,创建一个 Feature.xml 文件,内容如下。
    XML

    <Feature Title="New Simple Form Toolbar Button"
    Scope
    ="Web"
    Id
    ="GUID"
    xmlns
    ="http://schemas.microsoft.com/sharepoint/">
    <ElementManifests>
    <ElementManifest Location="Elements.xml" />
    </ElementManifests>
    </Feature>
  2. 需要替换上面的 GUID 占位符。您可以运行 guidgen.exe来生产一个GUID,该命令位于 Local_Drive:\Program Files\Microsoft Visual Studio 8\Common7\Tools下。

  3. 在SimpleFormToolbarButton文件夹中创建一个Elements.xml 文件,该文件指向一个.aspx文件,如下。
    XML
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction Title="Simple"
    Sequence
    ="10"
    RegistrationType
    ="List"
    RegistrationId
    ="104"
    Location
    ="EditFormToolbar"
    Id
    ="Simple Toolbar">
    <UrlAction Url="/_layouts/SampleUrl.aspx" />
    </CustomAction>
    </Elements>

     

  4. 为了测试该Feature,我们创建了一个 SampleUrl.aspx 页面,输出 "Hello, world!"。将其放在 TEMPLATE\LAYOUTS 目录中.

    <html>
    <head runat="server">
    <title>Sample Page</title>
    </head>
    <body>
    <p>Hello, world!</p>
    </body>
    </html>
  5. 在命令行中,输入下列命令安装并在特定网站上激活该Feature。
    a. stsadm -o installfeature -filename SimpleFormToolbarButton\Feature.xml
    b. stsadm -o activatefeature -filename SimpleFormToolbarButton\Feature.xml -url http://Server/Site/Subsite

  6. 导航到某通知条目的编辑窗体中,试试我们新创建的按钮吧。

posted @ 2008-07-14 18:14  Sunmoonfire  阅读(573)  评论(0编辑  收藏  举报