Feature/Site Template Association

Feature/site template associations allow you to associate new Features and functionality with existing site definition configurations so that, when sites are provisioned, the Features are automatically included in provisioning. Two Features are involved in a Feature/site template association: the Feature containing the functionality you want to add to an existing site definition configuration, and the Feature/site template association Feature itself, usually declared at the farm or Web application level, which binds the first Feature to the configuration.

Possible scopes:

  • Farm: Yes

  • Web Application: Yes

  • Site Collection: Yes

  • Web Site: No

Example

The following example shows the format of the Feature.xml file for a Feature/site template association:

Xml
<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="82E2EA42-39E2-4B27-8631-ED54C1CFC491"
  Title="Feature_Title"
  Description="Feature_Description"
  Version="12.0.0.0"
  Scope="Farm"
  xmlns="http://schemas.microsoft.com/sharepoint/"
  DefaultResourceFile="_Res">
  <ElementManifests>
    <ElementManifest Location="Feature_Elements.xml"/>
  </ElementManifests>
</Feature>

The element file for the preceding Feature.xml file might look like the following:

Xml
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <FeatureSiteTemplateAssociation Id="29D85C25-170C-4df9-A641-12DB0B9D4130" TemplateName="STS#0" />
  <FeatureSiteTemplateAssociation Id="29D85C25-170C-4df9-A641-12DB0B9D4130" TemplateName="STS#1" />
  <FeatureSiteTemplateAssociation Id="29D85C25-170C-4df9-A641-12DB0B9D4130" TemplateName="BDR#0" />
  <FeatureSiteTemplateAssociation Id="29D85C25-170C-4df9-A641-12DB0B9D4130" TemplateName="SPS#0" />
</Elements>

You can also globally associate a Feature with all Web site creation through all-site definitions on the front-end Web server. Associate the Feature with the global site definition by specifying GLOBAL#0 for the TemplateName attribute. Whenever you create a site the global site definition is applied, and so your Feature will also be applied.

For more information, see Feature/Site Template Associations.

Tags :


Community Content

Noelle Mallory - MSFT
Use GLOBAL and not GLOBAL#0 for the global site definition.

There is a typo in the article above. The global site definition is identified by GLOBAL and not GLOBAL#0. I have successfully deployed custom branding code this way.

Tags : contentbug

Chinmay Vartak
Global site definition Global#0 points to Custom site definition added using stsadm -o addtemplate
Whenever we add custom site definition using stsadm -o addtemplate command it is recognized as global site definition.
In the article above it points to custom site definition which are installed using stsadm command as they became global in template collection. so article points to feature stappling is possible with custom site definition also.
Process of associating feature with all site creations through all-site definitions is possible by using Global in templatename only. and you can narrow down to specific template by specifying #0,#1..
Tags :

Page view tracker