views:

894

answers:

2

I am developing publishing site and it will have complex tree structure.
Is there any way to deploy site structure (multiple sub sites - SPWeb) using SharePoint solution?
I know I can create site tree programmatically.

+4  A: 

I have been on a project with the same needs, but we didn't find the answer with the OOTB functionality of the feature framework. We also had to go through the object model and do the creation programmatically.

But instead of hard-coding the site structure, we took a different approach. Our solution was to implement a generic SiteCreation feature that takes an xml file as input. The xml defines the site structure and is read by the feature receiver which parses it and creates the specified sites.

I know that there is some coding involved in this solution, but I think the extra work is well spent, since the site structure will likely change numerous times before it reaches production.

Thomas Favrbo
:) I have already made some console application that generates site structure from XML. If you made feature in WSP where do you put xml and how do you access it? You deploy xml file too? Where?
Robert Vuković
Place the XML file in the feature folder along with the feature.xml file. In the feature.xml, add a custom Property element where the value specifies the site structure xml file. From the feature receiver class you can now access the filename from the property and load the XML.
Thomas Favrbo
+1  A: 

The default publishing portal (and collaboration portal) site definitions use a portal provisioning class to build the site structure based on an xml file (this is all out of the box for a MOSS installation).

You can see how the provisioning class is referenced in the webtemp file for the portal site definitions (12\TEMPLATE\1033\XML\webtempsps.xml). An example of the actual xml documents that are used can be found in 12\TEMPLATES\SiteTemplates\WebManifest - it's a fairly straight forward schema.

If you are creating a custom site definition based on publishing portal then you can re-use the provisioning class and provide your own xml document to build your custom site structure.

edwach
I skipped creating site definition and will make all customization with features. Right now we use console app to creates site from custom XML as Thomas suggested.
Robert Vuković