Features enable you to deploy site functionality at a site, site collection, Web application, or farm level either in a mode where users can see the feature in order to activate or deactivate it, or in a mode where it is hidden and always present. In addition to the features that you see as options to activate and deactivate on a site, as shown in Figure 9.1, most of the building blocks of SharePoint are implemented by using features such as document libraries, the issues list, and the records management functionality.
By using features to deploy custom functionality, you are able to:
Leverage the SharePoint structure for installing features at the site, site collection, Web application, or farm levels
Leverage the SharePoint structure for activating or deactivating features
Have SharePoint manage the feature definition across distributed SharePoint servers
Almost anything is possible when thinking about the potential uses for Office Server features because SharePoint has provided for a lot of different functionality options. This can make envisioning the scenarios in which you will use features difficult. Here are some examples to get the creative juices flowing:
Associating a workflow with a particular list type and site template
Adding an additional action for a list or library and customizing the actions menus for that library
Creating a custom list type with defined fields and making it available for all sites in a farm
Modifying a site template to include a feature definition for any new instances of that site template
Replacing a control within existing functionality with a control defined by your feature
Tip
If you want to further familiarize yourself with the possibilities that features present, take a look at the definitions that are used to create the SharePoint out-of-the-box functionality. You will be able to review how Microsoft used features to define lists, add actions, control navigation, and many other things and get a good introduction to feature definition files.
The feature.xml file provides a name and ID—as well as defines the properties, including dependences, files, and assemblies—for your feature.
The structure of the feature.xml file is
<Feature <!-- Required Feature Attributes --> Id = "Text" <!-- This is the GUID for the feature --> <!-- You can generate a GUID for your feature by using a GUID generator tool like the one provided with Visual Studio --> Scope = "Text" <!-- Values are Web (web site), Site (site collection), WebApplication (web application) or Farm (farm) --> <!-- Optional Feature Attributes --> Title = "Text" <!-- Feature title up to 255 characters --> Version = "Text" > <!-- Version number in 0.0.0.0 format --> Creator = "Text" <!-- Name of feature author --> Description = "Text" <!-- Description of purpose of the feature --> DefaultResourceFile = "Text" <!-- Specifies the path for the resource file to be used for resource descriptions. --> Hidden = "TRUE" | "FALSE" <!-- If set to TRUE, the feature and its status will not be visible to users --> ReceiverAssembly = "Text" <!-- Strong name for receiver assembly in the GAC to use for feature events. Requires you to specify receiver class as well. --> ReceiverClass = "Text" <!-- Class used by the event processor. Requires you to specify receiver assembly as well. --> RequireResources = "TRUE" | "FALSE" <!-- If set to TRUE, this tag will force SharePoint to check to see if a resource file is available for the current culture. If the file is not present, the feature will not be available for activation in the user interface. --> ActivateOnDefault = "TRUE" | "FALSE" <!-- This attribute is not valid for site or web scope features and if set to TRUE means the feature is activated during installation or web application creation. --> AlwaysForceInstall = "TRUE" | "FALSE" <!-- If set to TRUE, the feature is installed by force even if it is already installed --> AutoActivateInCentralAdmin = "TRUE" | "FALSE" <!-- This attribute is not valid if feature is enabled for the farm scope. If set to TRUE, the feature is activated by default in the scope --> ImageUrl = "Text" <!-- URL for image to be used next to feature name in the site features interface --> ImageUrlAltText = "Text" <!-- Alternate text to use if the image is not loaded --> SolutionId = "Text" <!-- Ties the feature to a specific solution --> <! — Child Elements --> <ElementManifests> <!-- Specifies manifests and files that make up the feature --> <ElementFile Location="Path"> <!-- Relative path to the supporting element file, if any --> </ElementFile> <ElementManifest Location="Path"> <!-- Required attribute that defines path to the manifest file --> </ElementManifest> </ElementManifests> <ActivationDependencies> <!--Specifies features that are dependencies for this feature --> <ActivationDependency FeatureId="GUID"> <!-- One to many feature dependencies specified by GUID --> </ActivationDependency> </ActivationDependencies> <Properties> <!-- Contains property names and values for the feature --> <Property Key="Text" Value="Text"> </Property> <!-- If included, one or more feature properties and the associated default value --> </Properties> </Feature>
To generate a GUID, you can use the guidgen.exe tool provided with Visual Studio. To create a new GUID for your feature, follow these steps:
1. | Open a command prompt on your server and navigate to
<system drive>:Program FilesMicrosoft Visual Studio 8Common7Tools. |
2. | Run guidgen.exe. |
3. | Select Registry Format, as shown in Figure 9.2. Figure 9.2. Using the GUID Generator tool to generate a new GUID
|
4. | Click the Copy button and paste the value into your feature.xml file. Delete the { } characters surrounding the GUID value. |
The feature.xml file is the core of the feature deployment, but the element types are where all the fun action is found. Each element type has its own function and can be used within the scopes it is designed for. The four scopes available for features are
Farm: A feature can be applied to all sites within the Web farm.
WebApplication: The Web application means that the feature is available for all sites within that Web application as defined in Central Administration.
Site: The site scope applies the features to all sites within that site collection.
Web: Features scoped for the Web are available to the site on which the feature is installed.
The following element types can be used within a feature deployed for any scope in SharePoint.
Control: The Control element allows you to replace a control with a different control. For example, you can use it to call a different ASCX page for the search control to use on a WSS site. Here is some sample code using the control element that is part of the content light-up feature provided with SharePoint out of the box.
<Control Id="SmallSearchInputBox" Sequence="100" ControlSrc="~/_controltemplates/searcharea.ascx"> </Control>
This content light-up feature is a farm-level feature that provides some standard interface components such as the search box on WSS sites and the custom action link for exporting an event or a contact.
Custom Action Group: The CustomActionGroup element type defines a grouping for custom actions. This tag is not necessary if you are adding or hiding a custom action to a particular list type.
The structure for the custom action group is shown in this code sample:
<CustomActionGroup Title="Text" <!-- Required attribute that provides the description for the action group. --> Location="Text" <!-- Required attribute that specifies a text string that tells SharePoint where to place the action. The text should match the name in the LinkSectionTable control on the page. --> Description="Text" <!-- Optional attribute for a longer description for the action group. --> Sequence="Integer" <!-- Optional number for ordering priority for the action group. --> Id="Text"> <!-- Optional value for unique identifier for the element. --> </CustomActionGroup>
Custom Action: The CustomAction element allows you to add actions for your feature. This code, from the content lightup feature, adds a custom control for exporting an event and is not in a custom action group because the custom action is bound to a list type and ID (the Event list).
<CustomAction Id="ExportEventToolbarButton" Location="DisplayFormToolbar" Title="$Resources:ContentLightup_EventToolbar_ ExportEventButton;" RegistrationType="List" RegistrationId="106"> <UrlAction Url="~site/_vti_bin/owssvr.dll?CS=109&Cmd=Display&List= {ListId}&CacheControl=1&ID={RecurrenceId}& Using=event.ics"/> </CustomAction>
The custom action for exporting an event shows up in the location DisplayFormToolbar for the display form for a calendar event, as shown in Figure 9.3.
The structure of the custom action element is shown in the following code sample. Make sure that you follow the CustomAction tag with the UrlAction tag that provides the URL for the action, as shown in the Custom Action Group section.
<CustomAction Title="Text" <!-- Required attribute that provides the action description to the user. --> Description="Text" <!-- Longer description for the action that is shown as a tool-tip or sub-description --> Id="Text" <!-- Optional value for unique identifier for the element. --> Location="Text" <!-- Optional attribute that specifies where the action will appear. If contained in a custom action group, location will equal the location of the CustomActionGroup element. The location could also be a part of a site settings menu, a toolbar item or menu item. --> RegistrationType="Text" <!-- Option attribute that allows you to create a per-item action. Allowable values are ContentType, FileType, List, or ProgID. --> RegistrationId="Text" <!-- Option attribute that provides the value for the registration type defined above. The value is the identifier of the list, content type, document or programmatic ID. --> GroupId="Text" <!-- Option attribute that identifies the action group such as "SiteManagement". If custom action is a subelement of CustomActionGroup, the value must match the GroupId of the CustomActionGroup. --> ContentTypeId="Text" <!-- Optional attribute that specifies the content type ID for the custom action to associate with. --> ImageUrl="Text" <!-- Optional attribute for a relative path for the action icon. --> RequireSiteAdministrator="TRUE" | "FALSE" <!-- Optional attribute that if set to TRUE, the action will only show for site administrators. --> Sequence="Integer" <!-- Optional value for ordering the action. --> Rights="Text" <!-- Optional value that lets you specify for which roles the action should appear. --> ShowInReadOnlyContentTypes="TRUE" | "FALSE" <!-- Optional value that if set to TRUE, the action will only be displayed for read-only content types. --> ShowInSealedContentTypes="TRUE" | "FALSE" <!-- Optional value that is set to TRUE, the action will only be displayed for sealed content types. --> ControlAssembly="Text" <!-- Optional attribute that specifies the assembly for the action. --> ControlClass="Text" <!-- Optional attribute that defines the class for the control assembly, if used. --> ControlSrc="Text"> <!-- Optional attribute that specifies source of the control. --> </CustomAction>
Hide Custom Action: This element hides a custom action defined by another custom action. The structure of the HideCustomAction element is shown in this sample code:
<HideCustomAction HideActionId="Text" <!-- Optional value that specifies the ID of the action you want to hide. --> Location="Text" <!-- Optional attribute that specifies the location of the action you want to hide. --> GroupId="Text" <!-- Option attribute that identifies the action group such as "SiteManagement". --> Id="Text"> <!-- Optional attribute that specifies the ID for this HideCustomAction element. --> </HideCustomAction>
There is one element that can be applied at the farm, Web application, or site scope levels. The Feature/Site Template Association element associates your feature with a site template and allows you to define features (custom or otherwise) that will be included in new sites created from the template when your feature is activated.
An example of the FeatureSiteTemplateAssociation element is the translation management functionality. When turned on, the code below associates the translation management with four sites.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <FeatureSiteTemplateAssociation Id="29D85C25-170C-4df9- A641-12DB0B9D4130" TemplateName="STS#0" /> <FeatureSiteTemplateAssociation Id="29D85C25-170C-4df9- A641-12DB0B9D4130" TemplateName="STS#1" /> <FeatureSiteTemplateAssociation Id="29D85C25-170C-4df9- A641-12DB0B9D4130" TemplateName="BDR#0" /> <FeatureSiteTemplateAssociation Id="29D85C25-170C-4df9- A641-12DB0B9D4130" TemplateName="SPS#0" /> </Elements>
The structure of the feature/site template association element is shown in the following code sample:
<FeatureSiteTemplateAssociation Id="Text" <!-- Required attribute that provides the GUID for the feature (see http://msdn2.microsoft.com/en-us/library/ aa544552.aspx). --> TemplateName="Text" /> <!-- Required attribute that provides the name of the associated site template. --> <Property <!-- Optional child element to provide properties for the association. If included, the property must have key and value tags. --> Key="IncludeInGlobalNavigation" Value="False" /> </FeatureSiteTemplateAssociation>
The DocumentConverter (if refers to xml element tag) element defines a document converter that processes a file and generates a copy of that file in the converted document type format.
The structure of the DocumentConverter element is shown in the following code sample:
<DocumentConverter Id="Text" <!-- Optional attribute for specifying the GUID for the document converter. --> Name="Text" <!-- Optional attribute for naming the document converter. --> App="Text" <!-- Optional attribute for the document converter executable--> From="Text" <!-- Optional attribute that specifies the extension of the source file. --> ConverterUIPage="Text" <!-- Optional attribute that specifies the extension of the target file. --> ConverterSpecificSettingsUI="Text" <!-- Optional attribute that provides the .ascx control for the converter configuration page. --> ConverterSettingsforContentType="Text"/> <!-- Optional attribute that specifies the .aspx page where administrators can configure the document conversion for each site content type. -->
There are several elements that can be deployed at the site scope level. Some of these items create items once, like content type and list templates, which can be used thereafter by other elements.
Content Type: The ContentType element defines a custom content type that will be created when the feature is activated.
Note
Because activation is an activity that you need to do only once, it is primarily useful for content types out of the box or for deploying an entirely new feature set at the site collection level.
The following code provides the structure for the ContentType element:
<ContentType ID="Text" .<!-- Required attribute that provides the ID for the content type. --> Name="Text" <!-- Required attribute provides a name for the content type. --> .Description="Text" <!-- Optional attribute that provides the longer description for the content type. --> Group="Text" <!-- Optional attribute that specifies to which group the content type should belong. --> ReadOnly="TRUE" | "FALSE" <!-- Optional attribute that if set to TRUE, makes the content type read-only. --> Hidden="TRUE" | "FALSE" <!-- Optional attribute that if set to TRUE, will hide the content type so that it is not presented as an option for the New button. --> Sealed="TRUE" | "FALSE" <!-- Optional attribute that if set to TRUE, makes the content type sealed. --> V2ListTemplateName="Text" <!-- Optional attribute that associates the content type with a WSS 2.0 list template. --> FeatureId="Text"> <!-- Optional attribute that provides the feature ID for the content type. --> <Folder TargetName="Text" <!-- Optional attribute for providing relative path for content type's resource folder. --> /> <FieldRefs> <!-- This section defines column references for your content type. --> <FieldRef ID="Text" <!-- Optional attribute that specifies the field ID this FieldRef references --> Name="Text" <!-- Optional attribute that provides a column name --> Description="Text" <!-- Optional attribute that provides long-name description for the field. --> DisplayName="Text" <!-- Optional attribute that provides the column display name for use in a form. --> Format="Text" <!-- Optional attribute that specifies formatting for columns. Options can be set to DateOnly, DateTime, ISO8601, ISO8601Basic, Dropdown (Choice column), RadioButtons (Choice Column), Hyperlink (URL column), Image (URL column). --> Required="TRUE" | "FALSE" <!-- Optional attribute that specifies whether or not the field is required. --> Filterable="TRUE" | "FALSE" <!-- Optional attribute that specifies whether or not the field can be used for filtering. --> FilterableNoRecurrence="TRUE" | "FALSE" <!-- Optional attribute that specifies if the column is filterable with no recurrences. --> Sortable="TRUE" | "FALSE" <!-- Optional attribute that specifies whether or not the field is available for sorting. --> Hidden="TRUE" | "FALSE" | "orResource" <!-- Optional attribute that specifies whether or not the field is hidden. --> Node="Text" <!-- Optional attribute that specifies the XML node that contains the field value. --> Aggregation="sum" | "count" | "average" | "min" | "max" | "merge" | "plaintext" | "first" | "last" <!-- Optional attribute that provides the action to take on the XPath expression if returned by Node value. --> NumLines="Integer" <!-- Optional attribute that limits the number of viewable lines for text editing. --> PIAttribute="Text" <!-- Optional attribute that specifies the attribute that will be used for document processing instruction. Must be paired with PITarget. --> PITarget="Text" <!-- Optional attribute that specifies the document processing instruction storage location. Must be paired with PIAttribute. --> PrimaryPIAttribute="Text" <!-- Optional attribute that specifies the attribute that will be used for document processing instruction. Must be paired with PrimaryPITarget and will trump any present PIAttributed. --> PrimaryPITarget="Text" <!-- Optional attribute the specifies the document processing instruction storage location. Must be paired with PrimaryPIAttribute and will trump any present PIAttribute.--> ReadOnly="TRUE" | "FALSE" <!-- Optional attribute that specifies whether or not field is read-only. If ready only, the field will not be displayed in new or edit forms. --> Sealed="TRUE" | "FALSE" <!-- Optional attribute that specifies whether or not the column is sealed. --> ShowInDisplayForm="TRUE" | "FALSE" <!-- Optional attribute that specifies whether or not the column will be included on the display form. --> ShowInEditForm="TRUE" | "FALSE" <!-- Optional attribute that specifies whether or not the column will be included on the edit form. --> ShowInFileDlg="TRUE" | "FALSE" <!-- Optional attribute that specifies whether or not the column will be included in the file dialog. --> ShowInListSettings="TRUE" | "FALSE" <!-- Optional attribute that specifies whether or not the column will be included on the new item form. --> ShowInNewForm="TRUE" | "FALSE" <!-- Optional attribute that specifies whether or not the column will be included on the new form. --> > </FieldRef> <RemoveFieldRef <!-- This element removes a field that is present in the parent content type from this content type. --> ID="Text"> <!-- Specifies the field ID of the column that you want to remove. --> </FieldRefs> <XMLDocuments> <XMLDocument <!-- This optional element defines XML documents to be included in the content type. --> NamespaceURL="Text"> <!-- Optional value that provides path to the namespace for the XML document. --> </XMLDocument> </XMLDocuments> </ContentType>
Content Type Binding: The ContentTypeBinding element allows you to define a content type for a list that is defined in the onet.xml schema, because lists defined by the onet.xml schema cannot be modified directly.
The following structure is used for the ContentTypeBinding element.
<ContentTypeBinding ContentTypeId="Text" <!-- Required attribute that provides content type ID that you want to bind to the list. --> ListUrl="Text" <!-- Required attribute that provides a relative path for the list for which you want to bind the content type. --> />
Field Element: The Field element creates site columns for use in any list.
Here is an example on how this Field element is used within the report list template to create the fields for storing reports:
<Fields> <Field ID="{FA564E0F-0C70-4AB9-B863-0177E6DDD247}" Type="Text" Name="Title" ShowInNewForm="FALSE" ShowInFileDlg="FALSE" DisplayName="$Resources: core,Title;" Sealed="TRUE" SourceID= "http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" /> <Field ID="{2A16B911-B094-46e6-A7CD-227EEA3EFFDB}" Name="ReportDescription" StaticName= "ReportDescription" Description="$Resources: spscore,BizAppsFields_ReportDescription_ Description;" DisplayName="$Resources:spscore, BizAppsFields_ReportDescription_Name;" Group="$Resources:spscore,BizAppsFields_ReportGroup; " Type="Note" SourceID="http://schemas.microsoft. com/sharepoint/v3"></Field> <Field ID="{90884F35-D2A5-48dc-A39F-7BCBC9781CF6}" Name="SaveToReportHistory" StaticName= "SaveToReportHistory" Description="$Resources: spscore, BizAppsFields_ReportSaveToReportHistory_ Description;" DisplayName="$Resources:spscore, BizAppsFields_ReportSaveToReportHistory_Name;" Group="$Resources:spscore,BizAppsFields_ ReportGroup;" Type="Boolean" SourceID= "http://schemas.microsoft.com/sharepoint/v3"> <Default>0</Default> </Field> <Field ID="{1BE428C8-2C2D-4e02-970B-6663EB1D7080}" Name="ParentId" StaticName="ParentId" Description="$Resources:spscore,BizAppsFields_ ReportParentID_Description;" DisplayName= " $Resources:spscore,BizAppsFields_ ReportParentID_Name;" Group="_Hidden" ShowInNewForm="FALSE" ShowInEditForm="FALSE" ShowInFileDlg="FALSE" Type="Number" SourceID= "http://schemas.microsoft.com/sharepoint/ v3"></Field> <Field ID="{2E8881DA-0332-4ad9-A565-45B5B8B2702F}" Name="ReportOwner" StaticName="ReportOwner" Description="$Resources:spscore,BizAppsFields_ ReportOwner_Description;" List="UserInfo" DisplayName="$Resources:spscore,BizAppsFields_ ReportOwner_Name;" Group="$Resources:spscore, BizAppsFields_ReportGroup;" Type="User" SourceID="http://schemas.microsoft.com/sharepoint/ v3"></Field> <Field ID="{D8921DA7-C09B-4a06-B644-DFFEBF73C736}" Name="ReportCategory" StaticName="ReportCategory" Description="$Resources:spscore, BizAppsFields_ReportCategory_Description;" DisplayName="$Resources:spscore,BizAppsFields_ ReportCategory_Name;" Group="$Resources:spscore, BizAppsFields_ReportGroup;" Type="Choice" SourceID="http://schemas.microsoft.com/ sharepoint/v3"> <CHOICES> <CHOICE>$Resources:spscore,BizAppsFields_ ReportCategory_Choice1;</CHOICE> <CHOICE>$Resources:spscore,BizAppsFields_ ReportCategory_Choice2;</CHOICE> <CHOICE>$Resources:spscore,BizAppsFields_ ReportCategory_Choice3;</CHOICE> </CHOICES> </Field> <Field ID="{BF80DF9C-32DC-4257-BCF9-08C2EE6CA1B1}" Name="ReportStatus" StaticName="ReportStatus" Description="$Resources:spscore,BizAppsFields_ ReportStatus_Description;" DisplayName= "$Resources:spscore,BizAppsFields_ ReportStatus_Name;" Group="$Resources: spscore,BizAppsFields_ReportGroup;" Type="Choice" SourceID="http://schemas.microsoft.com/ sharepoint/v3"> <CHOICES> <CHOICE>$Resources:spscore,BizAppsFields_ ReportStatus_Final;</CHOICE> <CHOICE>$Resources:spscore,BizAppsFields_ ReportStatus_Preliminary;</CHOICE> <CHOICE>$Resources:spscore,BizAppsFields_ ReportStatus_PeriodToDate;</CHOICE> </CHOICES> </Field> <Field ID="{27C603F5-4DBE-4522-894A-AE77715DC532}" Name="ReportHistoryLink" StaticName= "ReportHistoryLink" Group="_Hidden" ReadOnly= "TRUE" Type="Computed" DisplayName= "$Resources:spscore,BizAppsFields_ ReportHistory_Name;" SourceID="http://schemas. microsoft.com/sharepoint/v3"> <FieldRefs> <FieldRef Name="ContentType"/> <FieldRef Name="ID"/> </FieldRefs> <DisplayPattern> <IfEqual> <Expr1><Column Name="ContentType"/ ></Expr1> <Expr2>$Resources:spscore, BizAppsContentTypes_Report;</Expr2> <Then> <HTML><![CDATA[<a href="]]></ HTML><ListUrlDir/><HTML><![CDATA[/ Forms/rpthist.aspx?FilterField1= ParentId&FilterValue1= ]]></HTML><Field Name="ID"/ ><HTML><![CDATA[&ListId=]]></ HTML><List/><HTML><![CDATA[&ID=]] ></HTML><ID /><HTML><![CDATA[">]] ></HTML> <HTML>$Resources:spscore, BizAppsFields_ReportHistory_ ViewHistory;</HTML> <HTML><![CDATA[</a>]]></HTML> </Then> <Else /> </IfEqual> </DisplayPattern> </Field>
This code results in a list showing the fields that you see when you upload a document to a report library, as shown in Figure 9.4.
Cross-Ref
For more information on all the functionality provided by report libraries, see Chapter 15.
List Instance: The ListInstance element instantiates a list when your feature is activated and can also be applied at the Web scope level.
The following code sample shows the structure of the ListInstance element:
<ListInstance Id="Text" <!-- Required attribute for unique identifier for the list instance. --> FeatureId="Text" <!-- Required attribute for GUID of the feature with which this list instance is associated. --> TemplateType="Integer" <!-- Required attribute that provides integer ID for the list template to use. --> Title="Text" <!-- Required attribute that gives list title. --> Url="Text" <!-- Required attribute that provides relative place to where the list should be created. --> Description="Text" <!-- Optional attribute that provides list description. --> OnQuickLaunch="TRUE" | "FALSE" <!-- Optional attribute that specifies whether or not the list should be placed on the quick launch.--> QuickLaunchUrl="Text" <!-- Optional attribute that provides the URL that the Quick Launch link should point to. --> RootWebOnly="TRUE" | "FALSE"> <!-- Optional attribute for whether or not the list only exists in root web site. --> <Data> <Rows> <Row> <!-- Provides default data to include when the list is instantiated. --> </Row> </Rows> </Data> </ListInstance>
List Template: The ListTemplate element calls a list defined in the schema.xml file. This feature element can also be applied at the Web scope level.
Note
Because defining a list template is an activity that you need to do only once, it is primarily useful for list templates out of the box or for deploying an entirely new feature set at the site collection level.
The following code sample shows the structure of the ListTemplate element:
<ListTemplate DisplayName = "Text" <!-- Required attribute that provides name of list definition. --> BaseType = "0" | "1" | "2" | "3" | "4" <!-- Required attribute that provides the default schema for list created from this list definition. Base type 1=document library. --> Name = "Text" <!-- Required attribute that provides name reference used to find the folder that provides the schema.xml. SharePoint will look in the features directory for a nameschema.xml file --> Description = "Text" <!-- Optional attribute that provides a description. --> Default = "TRUE" | "FALSE" <!-- Optional attribute that specifies whether or not this list will be included on all new SP lists. --> VersioningEnabled = "TRUE" | "FALSE" <!-- Optional attribute that if set to TRUE, turns versioning on the list on. --> AllowDeletion = "TRUE" | "FALSE" <!-- Optional attribute that specifies whether or not the lists created through the template can be deleted. --> AllowEveryoneViewItems = "TRUE" | "FALSE" <!-- Optional attribute --> AlwaysIncludeContent = "TRUE" | "FALSE" <!-- Optional attribute that when set to TRUE will make list templates created from this list definition include content when saved. --> CacheSchema = "TRUE" | "FALSE" <!-- Optional attribute --> Catalog = "TRUE" | "FALSE" <!-- Optional attribute that when set to TRUE means that list definition is for a list, site or web part gallery. --> Category = "Libraries" | "Communications" | "Tracking" | "Custom Lists" <!-- Optional attribute that specifies which category the lists created from the template should be associated. --> DisableAttachments = "TRUE" | "FALSE" <!-- Optional attribute that specifies whether or not lists will allow attachments. --> DisallowContentTypes = "TRUE" | "FALSE" <!-- Optional attribute that if TRUE specifies that content types can be managed. --> DontSaveInTemplate = "TRUE" | "FALSE" <!-- Optional attribute that if set to true, will exclude content from being saved when a template is being created from the list. --> EditPage = "Text" <!-- Optional attribute that provides path to page for modifying the list settings. --> EnableModeration = "TRUE" | "FALSE" <!-- Optional attribute that if set to TRUE will create a list that requires content approval. --> FeatureId = "Text" <!-- Optional attribute that associates a Feature GUID with this list. --> FolderCreation = "TRUE" | "FALSE" <!-- Optional attribute that if set to TRUE allows folders to be created in the list. --> Hidden = "TRUE" | "FALSE" <!-- Optional attribute that if set to TRUE will hide the list template from the create page. --> HiddenList = "TRUE" | "FALSE" <!-- Optional attribute that is set to TRUE if lists created from this template will be hidden. --> Image = "URL" <!-- Optional attribute that provides path to icon for the list. --> NewPage = "Text" <!-- Optional attribute that specifies alternative page to be used for creating a new list from this template. --> NoCrawl = "TRUE" | "FALSE" <!-- Optional attribute that if set to TRUE will exclude list results from search results. --> OnQuickLaunch = "TRUE" | "FALSE" <!-- Optional attribute that if set to true will add a link to the Quick Launch for lists created from the template. --> SecurityBits = "Text" <!-- Optional attribute that allows you to define list security for the read, write and schema design roles for all lists other than document libraries. --> Sequence = "Integer" <!-- Optional attribute that specifies the order that you want the template to appear on the create page. --> SetupPath = "Text" <!-- Optional attribute that specifies the path to the folder containing the list definition file and assumes that the path is relative to the templates directory. --> SyncType = "Text" <!-- Optional attribute --> Type = "Integer" <!-- Optional attribute that provides a unique identifier for the template. --> Unique = "TRUE" | "FALSE"> <!-- Optional attribute that when set to TRUE, the list template can only be used to create lists during site creation. --> </ListTemplate>
Module: The Module element, which can also be applied at the Web scope level, builds a packing list of files to be implemented to support the feature.
Here is the code the publishing resources features use to include the pages for a publishing site:
<Module Name="PageLayouts" Url="_catalogs/masterpage" Path="" RootWebOnly="TRUE"> <File Url="WelcomeLinks.aspx" Type="GhostableInLibrary" > <Property Name="Title" Value="$Resources:cmscore, PageLayout_WelcomeLinks_Title;" /> <Property Name="MasterPageDescription" Value= "$Resources:cmscore,PageLayout_WelcomeLinks_ Description;" /> <Property Name="ContentType" Value="$Resources: cmscore,contenttype_pagelayout_name;" /> <Property Name="PublishingPreviewImage" Value= "~SiteCollection/_catalogs/masterpage/ $Resources:core,Culture;/Preview Images/ WelcomeLinks.png, ~SiteCollection/_catalogs/ masterpage/$Resources:core,Culture;/ Preview Images/WelcomeLinks.png" /> <Property Name="PublishingAssociatedContentType" Value=";#$Resources:cmscore,contenttype_ welcomepage_name;;#0x010100C568DB52D9D0A14D9B2FD CC96666E9F2007948130EC3DB064584E219954237AF390064 DEA0F50FC8C147B0B6EA0636C4A7D4;#" /> </File> <File Url="VariationRootPageLayout.aspx" Type= "GhostableInLibrary" > <Property Name="Title" Value="$Resources:cmscore, PageLayout_VariationRootLayout_Title;" /> <Property Name="ContentType" Value="$Resources: cmscore,contenttype_pagelayout_name;" /> <Property Name="PublishingAssociatedContentType" Value=";#$Resources:cmscore,contenttype_ redirectpage_name;;#0x010100C568DB52D9D0A14D9B2FD CC96666E9F2007948130EC3DB064584E219954237AF3900FD 0E870BA06948879DBD5F9813CD8799;#"/> <Property Name="PublishingHidden" Value="true" /> </File> </Module>
The structure of the Module element is shown in the following code sample:
<Module Name="Text" <!-- Required attribute for name of file set --> List="Integer" <!-- Optional attribute which specifies the type of list as defined in onet.xml --> IncludeFolders="Text" <!-- Optional attribute that specifies whether or not to include sub-folders to contain files --> Path="Text" <!-- Optional attribute that specifies the URL for the file set. --> RootWebOnly="TRUE" | "FALSE" <!-- Optional attribute that if set to TRUE will only copy the files to the root web site of the site collection. --> SetupPath="Text" <!-- Optional attribute that specifies the location for the sources files and is assumed to be located to the element if blank. Used to be the path variable. --> Url="Text"> <!-- Optional attribute that provides the URL of the target folder in which you want the files placed. --> <File Url="Text" <!-- Required attribute that provides the URL for the target file --> Name="Text" <!-- Optional attribute that specifies the file name. --> Path="Text" <!-- Optional attribute for the source of the file (URL). --> IgnoreIfAlreadyExists="TRUE" | "FALSE" <!-- Optional attribute that if set to TRUE will copy the file even if it already exists. --> Type="Text" <!-- If present, specifies that you want the file to be cached on the front-end web server. If your file is stored in a document library, the value will be GhostableInLibrary. If your file is stored somewhere other than a document library, the value is set to Ghostable. --> NavBarHome="TRUE" | "FALSE"> <!-- Optional attribute that if set to TRUE, indicates that this file is the home page for the top navigation bar in the site. --> </File> <AllUsersWebPart <!-- Tag to use if your file is a web part. --> WebPartOrder="Integer" <!-- Required attribute that specifies the vertical order of the web part in the zone. --> WebPartZoneID="Text"> <!-- Required attribute that provides the ID of the web part zone to insert the web part in. --> </AllUsersWebPart> <NavBarPage <!-- Provides file information to the Nav Bar so that it can be linked. --> ID="Integer" <!-- Required attribute that provides the ID for the page. --> Name="Text" <!-- Required attribute that provides the text for the page that will show in the nav bar. --> Position="Text"> <!-- Optional attribute that provides the position of the item in the navigational bar. --> </NavBarPage> <View <!-- Allows you to provide view values for files that are views. --> Name = "Text" <!-- Required attribute that provides a name for the view. --> DisplayName = "Text" <!-- Required attribute that provides a display name for the view. --> Hidden = "TRUE" | "FALSE" <!-- Optional attribute that when set to TRUE, hides the view. --> Url = "URL" <!-- Optional attribute that provides the target URL of the view. --> DefaultView = "TRUE" | "FALSE" <!-- Optional attribute that when set to TRUE, indicates that this is the default view. --> Threaded = "TRUE" | "FALSE" <!-- Optional attribute that if TRUE shows items as threaded. --> Type = "HTML" | "Chart" | "Pivot" <!-- Optional attribute that renders view as HTML, Chart or Pivot. --> Scope = "Text" <!-- Optional attribute that sets the limit for which items are returned. FilesOnly will return files of current folder, Recursive will show all files in all folders, RecursiveAll will show all files and all subfolders of all folders. --> List = "Integer" <!-- Optional attribute that specifies the type of list as defined in the onet.xml file. --> AggregateView = "TRUE" | "FALSE" <!-- Optional attribute that when set to TRUE indicates that the view is a merge forms view for a form library. --> BaseViewID = "Integer" <!-- Optional attribute that specifies the ID of the base view. --> FailIfEmpty = "TRUE" | "FALSE" <!-- Optional attribute that when set to TRUE, returns a HTTP error code if no items are returned in the view. --> FileDialog = "TRUE" | "FALSE" <!-- Optional attribute that when set to TRUE displays the view in file dialogs. --> FPModified = "TRUE" | "FALSE" <!-- Optional attribute that when set to TRUE indicates that the file has already been modified and cannot be modified within SharePoint UI. --> FreeForm = "TRUE" | "FALSE" <!-- Optional attribute that when set to TRUE allows alternate field formatting for view columns. --> OrderedView = "TRUE" | "FALSE" <!-- Optional attribute that when set to TRUE indicates that the view is ordered. --> Path = "Text" <!-- Optional attribute that provides the source path for the view. --> ReadOnly = "TRUE" | "FALSE" <!-- Optional attribute that when set to TRUE marks the view as read-only. --> RecurrenceRowset = "TRUE" | "FALSE" <!-- Optional attribute that when set to TRUE will show recurring values as individual line items. --> RowLimit = "Integer" <!-- Optional attribute that specifies maximum number of rows to return in an HTML view. --> ShowHeaderUI = "TRUE" | "FALSE"> <!-- Optional attribute that if set to TRUE enables sorting and filtering from column headers. --> </View> </Module>
Workflow: The Workflow element calls a workflow. The following code sample shows the structure of the Workflow element:
<Workflow Name="Text" <!-- Required attribute that provides value that is displayed in WSS interface. --> Id="Text" <!-- Required attribute that provides workflow GUID. --> CodeBesideAssembly="Text" <!-- Required attribute for code beside assembly. --> CodeBesideClass="Text" <!-- Required attribute for workflow class for code beside assembly file. --> Title="Text" <!-- Optional attribute for title of workflow. --> Description="Text" <!-- Optional attribute for workflow description. --> AssociationUrl="Text" <!-- Optional attribute for the URL to the association form. --> InstantiationUrl="Text" <!-- Optional attribute for the URL to the instantiation form. --> ModificationUrl="Text" <!-- Optional attribute for the URL to the form used to modify the workflow. --> TaskListContentTypeId="Text" > <!-- Optional attribute that specifies the content type ID for the content type associated with the workflow task list. --> <AssocationData> <!-- Optional element that provides XML data to pass to the workflow association form. --> </AssocationData> <MetaData> <!-- Optional element that defines additional metadata to associate with the workflow. --> </MetaData> </Workflow>
Like the List Instance, List Template, and Module element types, the Receiver element type is defined in the site scope section and can be applied at either the site scope or Web scope level. The Receiver feature element registers an item event receiver.
The structure of a Receiver element is shown in the following code sample:
<Receivers ListTemplateId = "Text" <!-- Optional attribute that specifies the ID of the list template that the event applies to. --> ListTemplateOwner = "Text"> <!-- Optional attribute that specifies the GUID of the list template owner. --> </Receivers> <Receiver> <Assembly></Assembly> <!-- The assembly tag must be in the format of Name, Version=0.0.0.0, Culture=neutral, PublicKeyToken=xx --> <Class></Class> <!-- The class tag provides the fully qualified name of the class. --> <Data></Data> <!-- The data element passes parameters to the event receiver. --> <Name></Name> <!-- Event receiver name --> <Type></Type> <!-- Provides the type of event. --> <SequenceNumber></SequenceNumber> <!-- Specifies the sequence number used for the event registration. --> </Receiver>