Sharepoint site template - feature scope

Tag: sharepoint Author: bixuling Date: 2009-07-19

I created a site definition that I will use as a site template for a SPWeb object. My web can only be provisioned as a child of a site (SPSite) using a certain Sharepoint template. When I provision the web I want several features that compose my custom site definition to be activated at web level, and several other to be activated at site level (for the parent site). How can I achieve this?

Best Answer

When you create a Site Definition, you will have a Tag called Configuration that has Sub Tags called WebFeature and SiteFeature.

You can specify all the Features ID in the respective section so that you will have those Features activated when you create a Site out of it.

 <Configuration ID="0" Name="Basic">      
    <Feature ID="00BFEA71-1C5E-4A24-B310-BA51C3EB7A57" />
    <!-- Three-state Workflow Feature -->
    <Feature ID="FDE5D850-671E-4143-950A-87B473922DC7" />
    <Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5" />
    <!-- TeamCollab Feature -->
    <Feature ID="F41CC668-37E5-4743-B4A8-74D1DB3FD8A4" />
    <!-- MobilityRedirect -->


Hope this helps


But will the features activate on the site if I create a web out of the template as a child of the site?
I ended up doing programatically, when i provision the web I also add the features to the parent site feature collection.