I've seen the term "feature stapling" used around this site and some blogs. What exactly does this mean? My best guess is that it has something to do with dynamically activating features from other features.
Feature stapling is a technique that allows for a feature to be stapled to a site definition by using a support "stapler" feature that defines which features are attached to which site definition.
This allows for a feature to be automatically activated on a site created from a site definition without the need to modify the definition files (onet.xml). This also means that:
- you can use stapling to attach features to ootb definitions,
- you can use it to "modify" a custom definition that has already been deployed and it's in use.
Anyway, you must remember that stapling does not affect sites that have already been created: the stapled feature will be activated only on new site, so you will need to manually activate the feature on any old site you may have.
To create a feature stapling infrastructure you will need at last two feature: the feature that needs to be stapled (ie: the feature you want to be automatically activated) and a feature that performs the stapling associaton. Es-Take the following element.xml file taken from a sample stapler feature:
<Elements xmlns="http://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>
As you see to define the stapling accociaton, the tag "FeatureSiteTemplateAssociation" is used. You will need to specify the ID of the feature that should be stapled, followed by the name of the site definiton the feature will be attacched to. Just remember that the site definition name should be in the # format.