Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Stapling Features to Site Definitions

Stapling Features to Site Definitions

Retired Content

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.

Stapling SharePoint features with site definitions, which relies on the FeatureSiteTemplateAssociation element, allows developers to attach features to both standard and custom site definitions without directly modifying them. Every new site that is based on a site definition with a stapled feature is created with that feature activated. Feature stapling is particularly useful when you want to add functionality to standard site definitions because editing standard site definition files is not a recommended practice.

The Training Management application uses feature stapling to associate the Contoso theme with the CONTOSOTRAINING site definition. The following code from the Contoso.RI.UpdateTheme solution uses feature stapling for the Contoso theme feature. This feature deploys and applies the Contoso theme to a site.

<Elements Id="ceaf7e5c-0d93-4fae-9426-b7311a8f574a" xmlns="http://schemas.microsoft.com/sharepoint/">
  <FeatureSiteTemplateAssociation Id="1d7f7c32-9a58-4127-ac0b-d2b1742e9f4e" TemplateName="CONTOSOTRAINING#0"/>
</Elements>

The Id attributes reference the ContosoTheme feature. The TemplateName attributes reference site definitions. The site definitions are referenced in the Webtemp.xml file that is located in the %CommonFiles%\microsoft shared\Web Server Extensions\12\TEMPLATE\1033\XML folder.

The following code is from the Feature.xml file of the Contoso theme feature stapler. The scope of the feature is Farm. This means that, when it is activated, the feature stapler staples the Contoso theme feature to the site definitions for any new sites in the SharePoint server farm.

<Feature Id="1c67a1c7-6f25-4fba-9dd0-a36197a9f637" Title="Contoso Theme Feature Stapler" Scope="Farm" Version="1.0.0.0" Hidden="FALSE" DefaultResourceFile="core" xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="ApplyTheme\featureElement.xml" /> 
  </ElementManifests>
</Feature>

If the feature stapler is deactivated, the existing sites still have the Contoso theme feature activated but no new sites will have the Contoso theme feature activated.

For more information about feature stapling, see the following topics:

For more information about site definitions, see Site Definitions and Configurations on MSDN. For more information about features, see SharePoint Feature on MSDN.


Retired Content

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.

Show:
© 2015 Microsoft