locked
Feature Staple and cutom template RRS feed

  • Question

  • Hello

     

    I have coded some features which need to be activated when a new site is created. It works very well with all site definitions. My stapling looks like

     

    Code Snippet

    Id="029101E3-4171-4c2a-917E-C0566FA07E3A" TemplateName="GLOBAL"/>
    Id="029101E3-4171-4c2a-917E-C0566FA07E3A" TemplateName="STS#1"/>

     

     

    Now I want to make this feature "stapled" with Custom template but it doesn't work. Here is what I've done.

     

    1. I have created a new template by using "save site as template" in site settings.

    2. I have saved stp file by dowloading it from Site template gallery

    3. I have used stsadm command with addtemplate option to add this template.

    4. I have used stsadm command with enumtemplates option to check that this template is well installed. I have got this line:

    testwebtemplate - Language: 1033 - Site Template: _GLOBAL_#0 - Template Id: 1

    5. I have added this line to my stapling feature:

    Code Snippet
    <FeatureSiteTemplateAssociation Id="029101E3-4171-4c2a-917E-C0566FA07E3A" TemplateName="_GLOBAL_#0"/>

     

     

    6. I have IISRESET and try to create a new site collection with testwebtemplate as template. My feature is not activated.

     

    After many search on the web, I have found this thread http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1632432&SiteID=17&wa=wsignin1.0 but it doesn't work when I use GLOBAL#0 as TemplateName in my xml file.

     

    Is it possible to staple features with custom template? If yes How can I solve my problem? Where is my mistake?

    Wednesday, June 4, 2008 1:40 PM

Answers

  • Hello,

    try to make your site as site definition, it will work for sure
    Marwan Tarek - MOSS MVP http://www.sharepointblogs.com/marwantarek
    Thursday, November 6, 2008 11:42 AM
  • http://msdn.microsoft.com/en-us/library/bb861862.aspx

    As you can see on msdn:
    "Causes the attachment of a Feature to all new instances of sites that use a given site definition, without modifying the site definition or creating code routines to activate the Feature on each site. Also known as a feature site template association"

    Feature stapling only works on site definitions, so the only way will be to make your template a site definition.


    Best regards,

    Jeroen
    Thursday, November 6, 2008 12:18 PM

All replies

  • I have the same problem. Anybody know how to associate features with custom template?
    Thursday, November 6, 2008 11:18 AM
  • Hello,

    try to make your site as site definition, it will work for sure
    Marwan Tarek - MOSS MVP http://www.sharepointblogs.com/marwantarek
    Thursday, November 6, 2008 11:42 AM
  • http://msdn.microsoft.com/en-us/library/bb861862.aspx

    As you can see on msdn:
    "Causes the attachment of a Feature to all new instances of sites that use a given site definition, without modifying the site definition or creating code routines to activate the Feature on each site. Also known as a feature site template association"

    Feature stapling only works on site definitions, so the only way will be to make your template a site definition.


    Best regards,

    Jeroen
    Thursday, November 6, 2008 12:18 PM
  • Thank you for quick reply...
    Thursday, November 6, 2008 1:29 PM