I just delivered an internal MOSS IW Ramp course in Münich and we have some discussions concerning the onet.xml and how to modify the content of the sites, which have been created using custom code directly after site has been created. You are most likely aware that during site provisioning, there's no such event available as the WebCreated, which would be raised when the web creation based on onet.xml has been done. This is quite a huge limitation, but then again, there are quite good workarounds for this.
- Create your own custom site definitions using browser and export that using WSS 3.0 Extensions for VS 2005. As part of the export process, the tools generate the necessary code and associations to be used. Unfortunately the extensions do not support WCM enabled sites, so it cannot be used in publishing sites.
- Use ExecuteUrl element to redirect the user to custom aspx page after the site has been created to be able to customize the site. Your custom aspx page might be located under the _layouts folder and there for we can easily point to that one using the xml elements within the onet.xml.
- Create the WebCreated event using the powerfull feature framework. I'll declare the steps below for more detailed information.
Steps for WebCreated event using feature receiver
Step-by-Step guide for manual creating of WebCreated event are the following:
- Create feature to deploy the default.aspx to root of the site using Module events
- Create feature with feature receiver class – This is used for the Site Created event
- Create site definition, which does not have directly default.aspx, rather use the feature developed above
- Set the order of the features so that the default.aspx feature is activated before the receiver feature
- In feature receiver feature, access the default aspx page, for example access the web part manager of the welcome page using following code
//look for the default page so we can mess with the web parts
//get the web part manager
This was extremely quick sample, but hopefully it's useful to you. I'll try to find some time to make more comprehensive example of this.