共用方式為


Modules

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Modules are defined in an element manifest similarly to how they are defined in an Onet.xml file to specify files with which to provision SharePoint sites.

Zero or more File elements are allowed as a child of the Module element. Use the AllUsersWebPart element to specify a Web Part instance inside a given page except for a list view Web Part. The View element specifies list view Web Parts to use on site pages. The NavBarPage element declares that the page containing this element should participate in the navigation bar structure. The Property element allows you to specify custom properties for a Feature.

An element manifest uses the following schema:

Elements

  Module

    File

      View

      AllUsersWebPart

      NavBarPage

      Property

The following schema is used within an Onet.xml file:

Configuration

  Modules

    Module

      File

        View

        AllUsersWebPart

        NavBarPage

        Property

Example

The following example registers a Web Part Feature that specifies custom properties:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="WebPartPopulation" Url="_catalogs/wp" RootWebOnly="TRUE">
    <File Url="MyWebPart.webpart" Type="GhostableInLibrary">
      <Property Name="MyGroup" Value="Business Information" />
      <Property Name="MyLocation" Value="Middle Right" />
    </File>
  </Module>
</Elements>

The next example registers a Feature that includes two files and that specifies a list view to display on one of the pages.

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="KnowledgeBasePages" Url="" Path="KnowledgeBaseFolder">
    <File Url="KnowledgeBases.aspx">
      <View List="KnowledgeBaseList" BaseViewID="0" WebPartZoneID="Left" WebPartOrder="0" />
    </File>
    <File Url="KnowledgeBaseLink.aspx"/>
  </Module>
</Elements>

See Also

Concepts

Module

How to: Provision a File