I thought Microsoft did a good job documenting sp2010. I am so frustrated that I can't find anything related to this. I have a web template project. All I want is to run bunch of code when a web is provisioned. I put the code in the featureactivated of the webtemplate and it seems the code is not kicking in (and no error is given).
|
|
I'm not really a developer but I'll take a stab at this one given that our team is currently looking into replacing our custom site definitions with Web templates for SP2010. Feel free to correct me if any of this is incorrect - I'm certainly at the learning stage when it comes to Web templates. At a basic level you will need to ensure that the feature (be it custom or out of the box) is activated. However, a more complex scenario involving sub site creation and feature dependency is described below. One possible cause for this issue is attempting to create sub sites (Webs) using a Web template which depends on a site collection scoped feature that is not activated - i.e. you put an inactive site collection scoped feature in the "SiteFeatures" section of the ONET.xml file. From what I understand SharePoint checks features in the SiteFeatures section of the ONET.xml file in the order specified. If a required site scoped feature is found but not active the above error is thrown. Note that this behaviour differs from that in SharePoint 2007 - back then any site scoped features were also activated for sub sites (this is a deliberate improvement in flexibility, not a bug). To get around the situation described above, one option is to remove the site collection (Site) scoped from the "SiteFeatures" section in the ONET.xml and instead use a Web scoped feature to activate the required feature using an event receiver. If you choose this option you will need to ensure that this new feature is placed above the other Web scoped features in the "WebFeatures" section of your ONET.xml file. Of course, the suitability of this fix depends on the scope of your Web template. If this is just a one off scenario you may wish to simply enable the required farm or site collection scoped feature manually using PowerShell. As James has said it would be helpful to know whether the required feature is custom or out of the box in order for us to assist further. See this post from Vesa Juvonen for more information: http://blogs.msdn.com/b/vesku/archive/2010/10/14/sharepoint-2010-and-web-templates.aspx#webtempelement |
|||
|
|
|
Site Collection scoped features are not automatically activated on the Site Collection when you create sub sites. |
|||||||
|