Features 是MOSS 2007以开箱即用的一套新功能。MOSS 2007提供的许多站点定义中的Document Library 是以Feature方式提供的,基于这个开箱即用的 Document Library Feature,也可以创建自己定制Document Library。
Feature 基础
首先让我们看一下组成Feature的目录和文件。Features 存储在SharePoint服务器的如下路径下:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES
每个Featrue在此路径下有自己的子目录,在每一个Feature子目录下会发现名字为Feature.xml的文件,它存储这关于Featrue的metadata.
Document Library Features
以下的Featrue.xml文件是MOSS自带的用于创建 DocumentLibrary Feature:
?xml version="1.0" encoding="utf-8" ?>
<!-- _lcid="1033" _version="12.0.4017" _dal="1"-->
<!-- _LocalBinding -->
<Feature Id="00BFEA71-E717-4E80-AA17-D<chmetcnv unitname="C" sourcevalue="0" hasspace="False" negative="False" numbertype="1" tcsc="0" w:st="on">0C</chmetcnv>71B360101"
Title="$Resources:core,documentlibraryFeatureTitle;"
Description="$Resources:core,documentlibraryFeatureDesc;"
Version="<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on">1.0.0</chsdate>.0"
Scope="Web"
Hidden="TRUE"
DefaultResourceFile="core"
xmlns=http://schemas.microsoft.com/sharepoint/>
<ElementManifests>
<ElementManifest Location="ListTemplates\DocumentLibrary.xml" />
</ElementManifests>
</Feature>
在这个XML文件中,以下关于Featrue的metadata 包含在Featrue 元素中。
ID: 一个GUID,用于唯一标识这个Feature;
Title:Feature 的名字,可以在网站内关于Site Featrues的页面中看到。
Description:对description的描述。
Version:Feature的版本;
Scope:其值可以是Web或Site,它指明了这个Feature是应用于整个的Site Collection还是仅仅用于单独的一个子站点。
Hidden:值可以是True或False.该设置指定了这个Feature是否在Site Feature页面上显示。
DefaultResourceFile: 资源文件名字,Feature依赖它提供其它附加的配置信息。
Feature.xml文件中的<ElementManifests>元素,这个元素包含了另一个XML文件的位置,而这个文件包含的<Elemnets>的内容是Feature要实现的。
<ElementManifest>元素指明了要使用一个名为 DocumentLibrary.xml的文件,它在ListTemplates子目录下。子目录和文件使用的是相对路径。以下是该文件的< Elements>元素内容,DocumentLibrary Feature实现之。
<?xml version="1.0" encoding="utf-8" ?>
<!-- _lcid="1033" _version="12.0.4017" _dal="1" -->
<!-- _LocalBinding -->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListTemplate Name="doclib"
Type="101"
BaseType="1"
OnQuickLaunch="TRUE"
SecurityBits="11"
Sequence="110"
DisplayName="$Resources:core,doclibList;"
Description="$Resources:core,doclibList_Desc;"
Image="/_layouts/images/itdl.gif"
DocumentTemplate="101" />
</Elements>
Resource Files
资源文件存储在如下目录中:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Resources
资源文件包含有键/值对的信息,用于向SharePoint提供本地化的能力。
我们看一下DisplayName的属性值的设置方法:
这个属性值是:$Resources:core,docLibList;这个值指明了docliblist的值是从core资源文件中读取的。
属性值中的$Resources:core这部分是和core.en-US.resx资源文件相对应的。Docliblist部分是和core资源文件中的docliblist<data>元素对应的。
Core资源文件中用于填充DisplayName和Description属性的xml文本如下:
<Data Name="doclibList">
<Value>Document Library</Value>
</Data>
<Data Name="doclibList_Desc">
<Value>Create a document library when you have a collection of documents or other files that you want to share. Document libraries support features such as folders, versioning, and check out.</Value>
</Data>
Feature 的另外一个优势
在SPS2003中,ONET.XML文件非常大,包含了大量的信息。随着Features的 到来,ONET.xml缩小了,因为Features用于组件化ONET.xml的内容。就像我们已经看到的这样,以前存在与ONET.xml文件中的 <ListTemlate>元素已经被转移到了Document Library Feature.其它开箱即用的列表也使用同样的方法。
创建自已的 Document Library Feature
Step 1: Create a directory for the Feature.
Create a new directory for your Feature in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES directory.
This example will use the directory named CustomDocumentLibrary.
Step 2: (Optional) Create a custom Resource file.
Take advantage of the ability to store all your display settings and other items whose values may change frequently in your own Resource file by creating one.
Create a new file named customDocumentLibrary.en-US.resx in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Resources directory.
Inside the file put the following XML:
<?xml version="1.0" encoding="utf-8"?>
<!-- _lcid="1033" _version="12.0.4017.1004" _dal="1" -->
<!-- _LocalBinding -->
<root>
<Data Name="customDocumentLibrary_Title">
<Value>Custom Document Library</Value>
</Data>
<Data Name="customDocumentLibrary_Folder">
<Value>Custom Document Library</Value>
</Data>
<Data Name="customDocumentLibraryDisplayName">
<Value>Custom Document Library</Value>
</Data>
<Data Name="customDocumentLibraryDescription">
<Value>Create a custom document library when you have a collection of documents or other files that you want to share. Custom document libraries support features such as folders, versioning, and check out.</Value>
</Data>
</root>
Save the file.
Step 3: Create the Feature.xml file for the Feature.
Create a GUID for your feature. You will need to insert this GUID into some of the XML in this document where you see <YOUR GUID HERE>.
You can create a GUID inside VS.NET 2005 or run the following SQL SELECT statement to return a new GUID. SELECT NewID()
Create a file named Feature.xml and place it in the CustomDocumentLibrary directory you just created.
If you performed Step 2 put the following XML in the file:
<?xml version="1.0" encoding="utf-8" ?>
<!-- _lcid="1033" _version="12.0.4017" _dal="1" -->
<!-- _LocalBinding -->
<Feature Id="<YOUR GUID HERE>"
Title="$Resources:customDocumentLibrary,customDocumentLibrary_Title;"
Description="$Resources:customDocumentLibrary,customDocumentLibraryDescription;"
Version="<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on">1.0.0</chsdate>.0"
Scope="Web"
Hidden="FALSE"
DefaultResourceFile="customDocumentLibrary"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="ListTemplates\CustomDocumentLibrary.xml" />
</ElementManifests>
</Feature>
If you did not perform Step 2 put the following XML in the file:
<?xml version="1.0" encoding="utf-8" ?>
<!-- _lcid="1033" _version="12.0.4017" _dal="1" -->
<!-- _LocalBinding -->
<Feature Id="<YOUR GUID HERE>"
Title="Custom Document Library"
Description="Create a custom document library when you have a collection of documents or other files that you want to share. Custom document libraries support features such as folders, versioning, and check out."
Version="<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on">1.0.0</chsdate>.0"
Scope="Web"
Hidden="FALSE"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="ListTemplates\CustomDocumentLibrary.xml" />
</ElementManifests>
</Feature>
Remember to replace <YOUR GUID HERE> with the GUID you created!
Save the file.
Step 4: (Optional) Create the <DocumentTemplate> element inside the ONET.XML file if you are using a custom Document Template for your custom Document Library.
Open the ONET.XML file for a custom site definition you have created (Please see the Creating a custom site definition in MOSS 2007 documentation for more details on how to create a custom site definition in MOSS 2007.)
Inside the ONET.XML file create a new <DocumentTemplate> element inside the <DocumentTemplates> element.
If you performed Step 2 use the following XML:
<DocumentTemplate
Path=“SAMPLE”
DisplayName="$Resources:customDocumentLibrary,customDocumentLibraryDisplayName;"
Type="4000"
Default="TRUE"
Description="$Resources:customDocumentLibrary,customDocumentLibraryDescription;">
<DocumentTemplateFiles>
<DocumentTemplateFile Name="doctemp\word\custom.dot"
TargetName="Forms/template.doc"
Default="TRUE"/>
</DocumentTemplateFiles>
</DocumentTemplate>
If you did not perform Step 2 use the following XML:
<DocumentTemplate
Path=”SAMPLE”
DisplayName="Custom Document Library"
Type="4000"
Default="TRUE"
Description=" Create a custom document library when you have a collection of documents or other files that you want to share. Custom document libraries support features such as folders, versioning, and check out.">
<DocumentTemplateFiles>
<DocumentTemplateFile Name="doctemp\word\custom.dot"
TargetName="Forms/template.doc"
Default="TRUE"/>
</DocumentTemplateFiles>
</DocumentTemplate>
Step 5: Create the ListTemplates sub directory under your new Feature directory.
In the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\CustomDocumentLibrary directory create a directory named ListTemplates.
Step 6: Create the CustomDocumentLibrary.xml file for the Feature.
Create a file named CustomDocumentLibrary.xml and place it in the ListTemplates directory you just created.
If you performed Step 2 use the following XML:
<?xml version="1.0" encoding="utf-8" ?>
<!-- _lcid="1033" _version="12.0.3820" _dal="1" -->
<!-- _LocalBinding -->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListTemplate
Name="doclib"
Type="4000"
BaseType="1"
OnQuickLaunch="FALSE"
SecurityBits="11"
DisplayName="$Resources:customDocumentLibrary,customDocumentLibraryDisplayName;"
Description="$Resources:customDocumentLibrary,customDocumentLibrary_Folder;"
Image="/_layouts/images/itdl.gif"
DocumentTemplate="4000"/>
</Elements>
If you did not perform Step 2 use the following XML:
<?xml version="1.0" encoding="utf-8" ?>
<!-- _lcid="1033" _version="12.0.3820" _dal="1" -->
<!-- _LocalBinding -->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListTemplate
Name="doclib"
Type="4000"
BaseType="1"
OnQuickLaunch="FALSE"
SecurityBits="11"
DisplayName="Custom Document Library"
Description="Custom Document Library"
Image="/_layouts/images/itdl.gif"
DocumentTemplate="4000"/>
</Elements>
*Note: You can add multiple <ListTemplate> elements here if you wish to create a Feature that deploys multiple document libraries at a time.
Step 7: Copy the contents of the DocLib sub directory into your new Feature directory.
In the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\CustomDocumentLibrary directory create a directory named DocLib.
Copy the contents of the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\DocumentLibrary\DocLib directory to the new DocLib directory you just created.
Step 8: (Optional) If you plan to use a custom Document Template and you performed Step 4 above, create a custom Document Template.
Open Microsoft Word.
Type in “Sample document template” into the document.
Click File | Save As
In the dropdown list that says Save as type: select Document Template (.dot)
Name the file custom.dot
Click the Save button.
Step 9: (Optional) Copy the custom Word Document Template you create that will server as the default Document Template for your new custom Document Library to the SharePoint server.
Copy the custom.dot file to the following directory on the SharePoint server:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\<NAME OF CUSTOME SITE DEFINITION>\DOCTEMP\WORD
Step 10: (Optional) Add the Feature to the site definition you want the feature to be installed on by default when the site is created. (Please see the Adding a Document Library Feature to a site definition in MOSS 2007 documentation.)
Step 11: Register the Feature with a SharePoint site via the STSADM.EXE command line utility.
On the SharePoint server type the following command on the command line to change to the directory stsadm.exe resides in:
cd “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN”
Then type the following command to install the feature on the SharePoint server:
stsadm -o installfeature -filename "CustomDocumentLibrary\feature.xml"
This example assumes you have created a SharePoint site at the following URL:
http://SharePointServerName/SiteDirectory/CustDocLib
To activate the feature on the SharePoint site mentioned above site use the following command:
stsadm –o activatefeature –filename “CustomDocumentLibrary\feature.xml” –url “http://SharePointServerName/SiteDirectory/CustDocLib”
*Note: You can also uninstall and deactivate features using the stsadm utility.
Uninstall command line: stsadm -o uninstallfeature -filename "CustomDocumentLibrary\feature.xml"
Deactivate command line: stsadm –o deactivatefeature –filename “CustomDocumentLibrary\feature.xml” –url “http://SharePointServerName/SiteDirectory/CustDocLib”
Step 12: Reset IIS.
On the SharePoint server type iisreset on the command line and wait for IIS to reset.
Step <chmetcnv unitname="a" sourcevalue="13" hasspace="False" negative="False" numbertype="1" tcsc="0" w:st="on">13a</chmetcnv>: (Assuming you did not do Step 10) Browse to the SharePoint site you registered the feature with. Browse to the Create web page and the custom Document Library will be available in the list of items to create.
Open Internet Explorer.
Browse to the http://SharePointServerName/SiteDirectory/CustDocLib site.
Click Site Settings
Click Create
Click Custom Document Library
Fill in the required information and to the Custom Document Library.
(If you created a custom Document Template) In the Document Template dropdown select Custom Document Library for the template.
Click Create.
If you created a custom Document Template clicking the new button on the Custom Document Library toolbar will open the custom Document Template you created.
Step 13b: (Assuming you did perform Step 10) Create a new SharePoint site with the site definition you edited in Step 10. Browse to the new site to see the custom Document Library already created for you.
Open Internet Explorer.
Create a new SharePoint site with the custom site definition you edited.
You will see the Custom Document Library already created for you and listed in the QuickLaunch Navigation on the left hand side of the site.
If you created a custom Document Template clicking the new button on the Custom Document Library toolbar will open the custom Document Template you created.
Congrats! You made your own custom Feature!
相关推荐
在实际应用中,为了满足企业的个性化需求,MOSS 2007的定制成为了一个关键环节。本篇将深入探讨MOSS 2007的定制技术及其应用场景。 1. **页面布局与Web部件定制** - 页面布局:MOSS 2007支持自定义页面布局,开发...
在这个过程中,如何将 Moss 2007 中的列表迁移到 Moss 2010 成为了一个重要的问题。本文将为您详细介绍如何将 Moss 2007 中的列表迁移到 Moss 2010,共有两种方法:复制粘贴和列表导入。 方法一:复制粘贴 复制...
创建一个安全组用于管理具有单点登录权限的用户和用户组。这可以通过 SharePoint 管理中心或命令行工具如 PowerShell 来完成。安全组应包含所有需要单点登录访问 MOSS 应用程序的用户或用户组。 ### 3. 配置 MOSS ...
MOSS2007作为SharePoint技术的一个重要版本,提供了丰富的开发接口和工具,为开发者提供了强大的自定义和扩展能力。 本课程的目标是为开发者提供MOSS2007开发的概览,包括开发环境的搭建、开发场景的介绍、WSS...
在本文中,我们将深入探讨如何在Microsoft Office SharePoint Server (MOSS) 2007中使用SharePoint Designer (SPD) 创建一个到期提醒工作流,无需编写任何代码。这种工作流对于跟踪合同、任务或其他重要事件的到期...
压缩包中的"SharePoint 2007教程.chm"是一个非常实用的学习资料,它可能包含了关于MOSS 2007的详细教程,涵盖上述所有主题。"MeetingRoomControl.sln"可能是一个示例项目,可以帮助你理解Webpart或Event Handler的...
- **运行安装向导**:下载并运行MOSS2007的安装文件,通常是一个.msi文件。 - **选择安装类型**:可以选择完整安装或最小安装。完整安装包含所有组件,而最小安装仅包含基础功能。 - **配置SharePoint Products ...
压缩包中的"InstallSolution.bat"文件很可能是一个批处理脚本,用于自动化部署解决方案到Moss服务器。部署过程中可能涉及解决方案包的创建、添加WebPart到WebPart Gallery、激活功能等步骤。熟练掌握这类脚本编写,...
Microsoft Office SharePoint Server 2007(简称MOSS 2007)是微软推出的企业级协作平台,它基于Windows SharePoint Services 3.0,为组织提供了一个集文档管理、团队协作、网站创建、业务流程自动化和信息整合于一...
在MOSS 2007(Microsoft Office SharePoint Server 2007)中创建一个使用Form Authentication(表单验证)的站点,是为了提供一种非Windows集成身份验证的登录方式,适用于那些不依赖于Active Directory(AD)域服务...
【内容类型】是Microsoft Office SharePoint Server 2007(MOSS 2007)中的一个重要特性,它允许用户自定义和管理信息的结构,从而实现更精细化的数据分类和控制。内容类型定义了一组共享的属性(元数据)、行为(如...
Microsoft Office SharePoint Server 2007(简称MOSS 2007)是微软发布的一款企业级协同办公平台,它构建在Windows SharePoint Services 3.0之上,提供了更高级的功能和服务,包括文档管理、工作流、网站创建、知识...
**Microsoft Office SharePoint Server 2007 (MOSS 2007...总的来说,MOSS 2007 是一个强大的文档管理工具,它通过集成多种功能和服务,为企业构建了一个安全、高效且易于扩展的文档管理体系,以应对21世纪的业务挑战。
标题中的“从MOSS2007升级到SharePoint2010”指的是将Microsoft Office SharePoint Server (MOSS) 2007平台升级至SharePoint Server 2010的过程。这一升级涉及到一系列的技术步骤和注意事项,确保系统的稳定性和数据...
**Microsoft Office SharePoint Server (MOSS) 2007** 是SharePoint 2007的一个高级版本,它增加了更多的高级特性和服务,如企业搜索、业务智能、增强的安全性和合规性支持等。MOSS 2007 为企业提供了全面的内容管理...
这可能包括详细的教程、代码示例、设计指南以及最佳实践,旨在帮助开发者深入理解如何在MOSS 2007环境中创建和集成自定义Web部件。 【标签】"moss"直接关联到Microsoft Office SharePoint Server,这是本主题的核心...
搜索功能在MOSS 2007中被设计为一种企业级解决方案,支持大规模数据的索引和快速检索。 **WCM架构与开发最佳实践** **内容管理技术** MOSS 2007提供了两种主要的Web内容管理(WCM)选项:发布门户和协作门户。发布...
【Moss+自定义Feature】是指在微软的MOSS(Microsoft Office SharePoint Server)平台上通过创建和部署自定义Feature来扩展和定制系统功能的一种技术。Feature是MOSS中一个核心的概念,它允许开发者打包并部署一系列...
MOSS 2007是SharePoint Server 2007的一个版本,它是微软Office System的重要组成部分。它旨在提升组织内的沟通和协作效率,通过集成多种工具和服务,如网站、文档库、列表和工作流,为企业提供一个统一的信息平台。...
在SharePoint开发领域,Microsoft Office SharePoint Server (MOSS) 2007是一个重要的企业级协作平台,提供了丰富的功能和接口供开发者扩展和定制。在本系列课程的第四部分,我们将深入探讨MOSS 2007中的...