I have created a publishing web template. Now I need to activate a feature once the site is provisioned.
In order to achieve this, I've created an event receiver with something like this:
public override void WebProvisioned(SPWebEventProperties properties)
{
base.WebProvisioned(properties);
using (SPWeb web = properties.Web)
{
SPFeatureCollection featureCollect = web.Features;
if (******)
{
featureCollect.Add(new Guid("FEATUREGUID"), true);
}
}
}
I want this feature only to be activated when a site is provisioned with my custom web template. What should I write in (**)?
I also accept other approaches.
Thank you.
UPDATE: Onet.xml parts:
<Lists>
<List FeatureId="00BFEA71-6A49-43FA-B535-D15C05500108" Type="108" Title="$Resources:core,discussions_Title;" Url="$Resources:core,lists_Folder;/$Resources:core,discussions_Folder;" QuickLaunchUrl="$Resources:core,lists_Folder;/$Resources:core,discussions_Folder;/AllItems.aspx" EmailAlias="$Resources:core,discussions_EmailAlias;" />
<List FeatureId="00BFEA71-D1CE-42de-9C63-A44004CE0104" Type="104" Title="Anuncios" Url="$Resources:core,lists_Folder;/$Resources:core,announce_Folder;">
<Data>
<Rows>
<Row>
<Field Name="Title">$Resources:onetid11;</Field>
<Field Name="Body">$Resources:onetid12;</Field>
<Field Name="Expires"><ows:TodayISO/></Field>
</Row>
</Rows>
</Data>
</List>
<List FeatureId="00BFEA71-2062-426C-90BF-714C59600103" Type="103" Title="$Resources:core,linksList;" Url="$Resources:core,lists_Folder;/$Resources:core,links_Folder;" />
<List FeatureId="00BFEA71-EC85-4903-972D-EBE475780106" Type="106" Title="$Resources:core,calendarList;" Url="$Resources:core,lists_Folder;/$Resources:core,calendar_Folder;" QuickLaunchUrl="$Resources:core,lists_Folder;/$Resources:core,calendar_Folder;/Calendar.aspx" EmailAlias="$Resources:core,calendar_EmailAlias;" />
<List FeatureId="00BFEA71-A83E-497E-9BA0-7A5C597D0107" Type="107" Title="$Resources:core,taskList;" Url="$Resources:core,lists_Folder;/$Resources:core,tasks_Folder;" QuickLaunchUrl="$Resources:core,lists_Folder;/$Resources:core,tasks_Folder;/AllItems.aspx" />
</Lists>
(...)
<WebFeatures>
(...)
<!-- Links List-->
<Feature ID="00bfea71-2062-426c-90bf-714c59600103" />
<!-- Documents Libraries-->
<Feature ID="6e53dd27-98f2-4ae5-85a0-e9a8ef4aa6df" />
(...)
<!-- Page loading feature -->
<Feature ID="3ce5c12e-b3fe-4996-9608-18b8dedc137b" />
<!-- The next Feature adds ListViewWebParts to the pages, but doesn't work here. It says that List Links doesn't exist -->
<!-- Activating it manually or via Event Receiver works -->
<!--<Feature ID="7fce2ec9-856c-4fc0-93b8-b82c78e4f227" />-->
</WebFeatures>