Feature Stapling

Causes the attachment of a Feature to all new instances of sites that use a given site definition, without modifying the site definition or creating code routines to activate the Feature on each site. Also known as a feature site template association,

Real World Example

A developer creates a Feature and to add it to every new Web site that is based on a specific site definition. The developer creates a feature-stapling Feature that includes mappings between the Feature and site definition.

Technical Details

Feature stapling is implemented through a Feature that is specifically designed to staple other Features to one or more site definitions. Feature stapling allows a Feature to be stapled to any new sites created from any site definition or from specific site definitions based on the template name identified in the appropriate WEBTEMP.xml file.

Following is an example of feature stapling that associates the Feature with only the STS site definition templates.

<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
   <FeatureSiteTemplateAssociation Id="00BFE171-1B17-4F72-28CB-1171C0140130" TemplateName="STS#0" />
   <FeatureSiteTemplateAssociation Id="00BFE171-1B17-4F72-28CB-1171C0140130" TemplateName="STS#1" />
   <FeatureSiteTemplateAssociation Id="00BFE171-1B17-4F72-28CB-1171C0140130" TemplateName="STS#2" />
</Elements>

Following is an example of feature stapling that associates the Feature with all site definitions.

<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
   <FeatureSiteTemplateAssociation Id="00BFE171-1B17-4F72-28CB-1171C0140130" TemplateName="GLOBAL" />
</Elements>

Support Details

Feature stapling starts only when the feature stapling entry is added. To add the Features to existing sites, or to sites later added through a restoration process, you must associate the Features with the sites by using some other method.