Feature Stapling
allows you to create a feature and then associate it with any site
definition without ever touching the site definition files themselves.
Your feature will be activated when the site is provisioned.
Stapling basically consist of two features:
Steps
Now whenever you create a new site using site definition specified in FeatureSiteTemplateAssociation staplee feature will automatically get activated.
Sample Project
refer click
Stapling basically consist of two features:
- Staplee Feature: The feature which will be stapled to an existing site definition
- Stapler Feature: The feature which will staple the staplee feature with site definition
Steps
- Create new Empty SharePoint Project.
- Create staplee feature which we want to get activated on site provisioning.
- Create Stapler feature with scope as Farm.
- Add new Empy Element "StaplerElementHelper" to the project.
- Edit Element.xml file
- Add follwing line<FeatureSiteTemplateAssociation Id="d3f566c2-b711-4ddb-808b-c4d0c00dac36" TemplateName="STS#0" />FeatureSiteTemplateAssociation is going to associate our steplee feature with site definition "STS#0"(team site).
Note: Replace value of Id with your staplee feature ID. You can also specify your own TemplateName.
your complete file will look like
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"><FeatureSiteTemplateAssociation Id="d3f566c2-b711-4ddb-808b-c4d0c00dac36" TemplateName="STS#0" />
</Elements> - Double click your Stapler Feature and Include "StaplerElementHelper" in "Items in feature". Remember it should be included in Stapler feature and not in staplee feature.
- Deploy it.
Now whenever you create a new site using site definition specified in FeatureSiteTemplateAssociation staplee feature will automatically get activated.
Sample Project
refer click
No comments:
Post a Comment