views:

430

answers:

5

Is there any way to do WSS 3.0 site provisioning? My client's requirement is attributes as variables that will be defined in XML format: Organization Name, Logo, Address, User and Role information. The client should be able to install this web application to any WSS production server by just defining the attributes in the XML file.

Is it possible to to write a utility to parse that well defined XML and provision the site accordingly?

+1  A: 

Yes, there are more than one.

Take a look at SharePoint Solution Generator which is in Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions.

You may create a site with all requirements of yours (pages, lists, document libraries...) and then generate a VS project that will create a SharePoint feature with all of your site. Then you may deploy that feature to any WSS production server.

You may alter the VS project to implement the logic to read your attributes from an additional xml file.

If the structure of your site is plain or you can save it as a template you may also write a small console application that reads the attribute xml file and create the site.

Han Fastolfe
A: 

Thanks for the reply, I have a VS 2008 Wss extension. Could you please provide me with a sample code snippet.

Thanks, Tejas

Tejas
+2  A: 

It's possible to provision sites from the object model, but creating entirely customized sites is beyond the scope of a single question. To get you started, you should take a look at the SPWebCollection.Add as well as the SPSiteCollection.Add.

To create a site collection and some subsites into one of your web applications, you could use something like this:

var farm = SPFarm.Local;
var solution = farm.Solutions.GetValue<SPSolution>("YourSolution.wsp");
var application = solution.DeployedWebApplications.First();
var sites = application.Sites;
using(var site = sites.Add("/", "Root Site", "Description", 1033, "YOURTEMPLATE#1", "YOURDOMAIN\SiteCollectionAdmin", "Site Collection Admin", "[email protected]")) {

    using(var rootWeb = site.RootWeb) {

        // Code customizing root site goes here

        using (var subSite = rootWeb.Webs.Add("SubSite", "Sub Site", "Description", 1033, "YOURTEMPLATE#2", false, false)) {

            // Code customizing sub site goes here

        }
    }
}
Hirvox
+1  A: 

Create a regular solution, or use the aforementioned solution generator to generate the .wsp file. Then create a small console application, that expects the variables you mentioned as parameters. With the code listed above, provision the new sitecollection from that solution, and store the entered parameters (Company name etc.) in the site in a list, or in the SPSite.Properties propertybag, from which you can then read them in custom webparts etc..

Colin
A: 

The SharePoint Data Population Tool available on CodePlex allows you to define sites with XML.

Alex Angas