This project is read-only.
Project Description
Hey folks,

This is a SharePoint Site definition example that allows you to use multi-level site defintions :)

Eric


Provisioning Scripts (Multi-Site Site Template)

Hehe, this solution has a lot of history amongst some of my colleagues. I'll save the small talk and get right to it.

A provisioning script allows a developer the ability to create a multi-site site definitions. You've probably seen this done plenty of times with a MOSS 2007 Publishing Site/Collaboration Site, where the creation of these sites provisions multiple sub-sites as well.

The way we'll be diving into this is by looking at the Publishing Portal Template that exists in MOSS 2007 natively.

If you navigate to the "12\Templates\1033\XML" you'll notice a series of "WebTemp" files (files that begin with WEBTEMP). For our purposes we'll be looking at the "webtempsps.xml", this file has many of the template definitions used in SharePoint since 03'.

Inside of the "webtempsps.xml" you'll notice a series of the "Template Elements" that contain references and descriptions to Site Templates which live in "12\Templates\SiteTemplates". Well since we're here, let's begin our walk-through.

1) Create a folder on your desktop to host the modified template files, name this "MultiSiteTemplate".
2) Copy the "webtempsps.xml" into this folder and rename it to "webtempmultisite.xml".
3) Now it's time to make some modifications to our new "webtemp" file. Remove all "Template" elements except for the element with the name attribute of "BLANKINTERNETCONTAINER".
This is a little dive into theory (since I will not be getting to theoretical in this example). If you review this "webtemp" element you'll notice it is has a few different attributes that are not consistent with some of the other "Template" elements. In particular you'll notice the "ProvisionAssembly", "ProvisionClass", and "ProvisionData". These 3 attributes are particularly special in regards to the what they do.

The "ProvisionAssembly" attribute is a reference to the assembly that will do all the work of interpreting our XML script we'll be building in the "ProvisioningData" (I'll speak to this in a moment). The "ProvisioningClass" attribute is the actual class reference to the class living in the assembly referenced in our "ProvisionAssembly" attribute. The "ProvisioningData" assembly is the script we are building to provision multiple site templates to be created when we create a site based on our template.

You can think of the "Provisioning" attributes as the references called when the provisioning workflow kicks off on site creation.**

4) Let's modify our "Template" element to look like the following:



< ?xml version="1.0" encoding="utf-8"? >
< !-- lcid="1033" version="12.0.4518" _dal="1" -- >
< !-- _LocalBinding -- >
< Templates xmlns:ows="Microsoft SharePoint" >
< Template Name="MULTISITECONTAINER" ID="1000" >
< Configuration ID="0" Title="Multi-Site Portal" Hidden="FALSE" ImageUrl="/_layouts/1033/images/IPPT.gif" Description="A Site that contains multiple unique sub-sites."
ProvisionAssembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
ProvisionClass="Microsoft.SharePoint.Publishing.PortalProvisioningProvider"
ProvisionData="xml\\MULTISITE\\InternetBlank.xml"
RootWebOnly="FALSE" DisplayCategory="Publishing" VisibilityFeatureDependency="97A2485F-EF4B-401f-9167-FA4FE177C6F6" >
< /Configuration >
< /Template >
< /Templates >




You'll notice the only thing that we changed are the generic items such as the name, ID, description, and title. One of the major changes we need to discuss is the change to the path of the "ProvisionData". The path is now "xml\\multisite\\InternetBlank.xml", this is going to soon be the location of our Provisioning Script when it's created. It's a good practice to create your own separate folders to keep the custom items away from the out of the box.

5) Since we haven't created our own "InternetBlank.xml", let's create that first. Create a folder in our working folder named "MultiSite". Copy "InternetBlank.xml" from "12\Templates\xml" to our "MultiSite" folder.

6) Let's make some important modifications to the copied "InternetBlank.xml" file. Modify this file to mimic this:



< ?xml version="1.0" encoding="utf-8" ? >
< portal xmlns="PortalTemplate.xsd" >
< web name="Home"
siteDefinition="BLANKINTERNET#1"
displayName="$Resources:cmscore,IPPTPortalRoot_DisplayName;"
description="$Resources:cmscore,IPPTPortalRoot_Description;" >
< webs >
< web name="News"
siteDefinition="SPSNHOME#0"
displayName="News"
description="Hosts all news fora site" / >
< /webs >
< /web >
< /portal >




What you're seeing right now is just a very readable XML file that is saying and doing a lot in a few lines.

The "portal" element is the root element with an attribute of an xmlns (xml namespace). This file is basing it's structure off of the "PortalTemplate.xsd" (12\Templates\XML).

The "web" element is referring to the root site created when this template is used. This element contains many generic elements that should be pretty straight forard to figure out. You'll notice a unique value in the "siteDefinition" attribute, at the end of the SiteDefinition name it's followed by "#1". This addition to the end of the value is a reference to the configuration that should be used in this site definition (this will be discussed in a later post).

The "webs" element contains a list of "web" elements that will be created as a child of the root "web" element. In our case, we're creating a "News" site and just like with the root web we have all of the same attributes.

7) Let's finish this up now. Copy our "webtemp" file to "12\Templates\1033\XML". Copy the "MultiSite" folder to "12\Templates\XML".

8) Let's give our new site a try. Reset IIS and go to a site that you'd like to create our new template.



Well, this was one that for a while I could only get to work on "special" occasions but I fleshed it out finally and this can be done as a common task.

Patrick Tisseghem has an awesome example of this in his book:
"Inside Microsoft Office SharePoint 2007"


Hope this helps.

~:)

Last edited Oct 17, 2008 at 5:06 PM by stallwoe, version 2