0

I have created a web template with 2 features, one is scoped site (to create web template) and the other is scoped web (this is for creating a list instance)

Every time i deploy the solution and create a subsite from this web template the list instance does not appear.

What i have to do is go into the subsite settings and activate the feature manually. Can this not be done automatically once a subsite is created?

2 Answers 2

0

Your web-scoped feature needs to be explicitly added to the <WebFeatures> section of your web template, see below:

<Project Title="Custom Site" ListDir="$Resources:core,lists_Folder;" UIVersion="4" xmlns:ows="Microsoft SharePoint">
    <NavBars>
    </NavBars>
    <Configurations>
        <Configuration ID="0" Name="CustomSite" MasterUrl="_catalogs/masterpage/v4.master">
            <Lists>
            </Lists>
            <SiteFeatures>
                <!-- "Custom Site" Web Template Feature -->
                <Feature ID="00000000-0000-0000-0000-000000000000" />
            </SiteFeatures>
            <WebFeatures>
                <!-- Custom List Instance Feature -->
                <Feature ID="00000000-0000-0000-0000-000000000000" />
            </WebFeatures>
        </Configuration>
    </Configurations>
</Project>

If you have done this, however your feature is still not being activated, do the following:

  • Check the SharePoint log files to see if it has attempted to activate your web-scoped feature. Your feature may be throwing an exception and not completing the activation phase as expected.
  • Using either SharePoint Designer or PowerShell, check that your custom web template has in fact been used to create to your new subsite.
0

You can associate a feature with a specific site template, but if you put "GLOBAL" instead of the template name, your feature will be activated for all websites created.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <FeatureSiteTemplateAssociation Id="29D85C25-170C-4df9-A641-12DB0B9D4130"  TemplateName="GLOBAL" />
</Elements>
1
  • Feature Stapling doesn't work with WebTemplates Commented Nov 5, 2012 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.