Mar 5, 2009

Changing a built-in site definitions and templates

One of the challenges in WSS 2.0 was adding new functionality to existing site definitions and templates. This was because the official guidance from Microsoft was to never edit an existing site definition or template once sites have been provisioned using it, and that developers should not modify the site definitions provided in the out - of - the - box installations, as future updates (hotfixes and service packs) could overwrite the files. To address this, Microsoft added the capability of Feature stapling.

Feature stapling involves creating a special Feature, known as a stapling Feature, that associates a Feature with an existing site template. Once a Feature has been stapled to a site template, any future sites provisioned using the site template will automatically activate the stapled Feature. This enables developers to customize site templates without actually changing the site template itself; instead they can append functionality without touching the source files that make up the site template.

Stapling is achieved using the < FeatureSiteTemplateAssociation > site element. This element accepts two attributes: Id , the ID of the Feature to be stapled, and TemplateName , the ID of the site template. For example, the following CAML contained in a Feature element manifest file would staple the MyFirstFeature to all future sites provisioned using the Blank Site site template ( STS#1 ), assuming the stapling Feature were activated:

 < ?xml version="1.0” encoding=”utf-8"? > 

No comments:

Post a Comment