Monday, May 18, 2009

How to activate a feature when site is created

If you have a feature that can only be activated in web level and you need the feature to be activated when the site is created, then you might need to read the following.

The key word is feature stapler, which allows you to tight a feature that you need to activate to a site template.

In summary,
1. you create a new feature that set the scope to "farm" level
2. in the element.xml, you create


FeatureSiteTemplateAssociation Id="2B3451F0-BC93-41A4-9FAD-3A81861D651A" TemplateName="STS#0"/
2B3451F0-BC93-41A4-9FAD-3A81861D651A : feature to be activated when site is created
STS#0 : STS is the template name, and 0 is the configuration ID in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML

Refer to http://sharepointmagazine.net/technical/development/introduction-to-sharepoint-feature-stapling-part-1

No comments:

Post a Comment