Are we able to code an event receiver on site collection creation? I have so custom site definitions, i do everything with features. So i need to activate a feature on site collection creation.
2 Answers
You have few events and you can write Event Receiver for WebProvisioned
Programmatically activating features
And here is the List of Feature GUID's
You can use feature activated, you then fire the feature off with feature stapling on the template.
[update] To activate publishing infrastructure for example:
<?xml version="1.0" encoding="utf-8" ?>
<Elements Id="fa899b9d-85dd-4e0b-82d1-7cf7f6577136" xmlns="http://schemas.microsoft.com/sharepoint/">
<FeatureSiteTemplateAssociation Id="21e613ec-e03f-4499-b1a4-3095d5786b29" TemplateName="SPSPERS#0" />
</Elements>
-
no i couldnt explain my question properly i guess. the feature i want to activate (on site collection creation) is not a feature i developed. it is a sharepoint feature that can be activated by powershell.– ozdoganNov 6, 2012 at 14:15
-
Then use feature stapling, webprovisioned, or create a new template which activates the feature. If you don't need to run feature activated then you just need to link the feature with the template, so when the template is used it adds the feature to the site automatically. Nov 6, 2012 at 14:17
-
2