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.
-
2It's really a question to google rather then ask a question. It's blog a lot. And the first page of search results provides answers both in general and in depth.– Yuri LeontyevCommented Apr 18, 2012 at 6:55
-
14Hmm. For one, I feel that asking it here lets the answers get peer-reviewed, and thus I can feel more confident the answer is correct. Also, SPArchaeologist's answer below is very concise and to the point; even if it is redundant with answers on the web, it's the answer that really made it click for me. Additionally, I really like the format of StackExchange sites, and would prefer as much content to live here as possible. But these are my opinions, and I'm not sure how squarely they line-up with the rules of this site..– DarylCommented Apr 23, 2012 at 0:24
-
2I'm with Daryl. I've googled and bing'd "feature stapling" and not one useful post could I find after a half-hour. Posting here would hopefully provide some noise filtering and deliver better results than say, fruitless wading through msdn.– Alan MCommented Jun 28, 2012 at 19:32
1 Answer
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.
Also, have a look to this msdn page that explains some further details (taken from the 2007 docs, 2010 version available here).
-
SP2010 documentation is here: Feature/Site Template Association– JohnCCommented Dec 7, 2015 at 10:56