Feature Stapling In SharePoint 2010
Feature Stapling is the great way if the site definition is already in use (and sites have been created). Feature Stapling has two features. A "Stapler" feature which staples another feature to the site definition and the "Staplee" feature which will be stapled.
For Example suppose you want to apply a custom Theme to all of the "Publishing site" site definitions. This can be solved by creating a feature which will apply the Custom theme to the site and it can be associated with the publishing site's site definition. Or Suppose if you want to activate a custom list to all the Team sites , this can also be solved creating a feature which on activating when you create a team site the custom list gets created.
How to Create Feature stapler .
1. First we need to create the Features (Staplee) which we want install on creation of site (publishing or team site etc.). How to Create feature.
2. Create a Feature Stapler as below
<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="https://schemas.microsoft.com/sharepoint/ " Id="C384D136-79A8-48BD-AF73-C630547F4D8E" Title="ExampleStapler" Description="This feature staples the
other feature to the Team Site definition. " Scope="Farm" Hidden="False" Version="1.0.0.0" />
3. Create an element xml which is nothing but where feature association takes place.In order to add element.xml we need to create a module in Visual studio 2010 and then add the element.xml
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
<FeatureSiteTemplateAssociation Id="b8f334a0-1ffe-420d-b6e2-54a9faa6ba95" TemplateName="STS#0" />
<FeatureSiteTemplateAssociation Id="07cb8bd4-7004-4021-8355-48d17de287e5" TemplateName="STS#0" />
<FeatureSiteTemplateAssociation Id="90C924A7-32F7-4C19-BD4C-AF49EF0563A9" TemplateName="STS#0" />
</Elements>
The FeatureSiteTemplateAssociationID element maps feature(The Features which we want to install on creation of Site) GUIDs to site definitions.
Feature-stapling won't affect any sites which have already been created from a site definition, only subsequent sites. The only way to do this is to activate your features individually on the site.
So Once you deploy Feature Stapler to web application level and then you create a team Site the associated(Stappled) features will get activated.
Comments
Anonymous
August 25, 2011
Excellent!Anonymous
May 24, 2012
"How to Create feature" link fails ...Anonymous
July 04, 2012
GoodAnonymous
May 02, 2013
The comment has been removedAnonymous
May 05, 2013
What I find with this method is when I use a "module" project type, it can only be deployed to Site collection ro web level, not web application or farm, which is more common for a feature stapling feature.Anonymous
July 01, 2013
I believe this is the "Create feature" link that is mentioned int he article: msdn.microsoft.com/.../cc263911%28office.12%29.aspx