Creating a Custom SharePoint 2007 Portal Site Definition using the PortalProvisioningProvider Class

Creating a set of sites and subsites for multiple teams by creating each site one at a time can be a bit of a drag and a definite administrative drain.  What would be nice is to be able to specify a set of sites in a predefined heirarchy that the can be used as a single reusable template.  This set of sites is what SharePoint 2007 calls a "portal" (The most overused word in the SharePoint world).  SharePoint 2007 gives you the ability to create a portal site definition by using the PortalProvisioningProvider contained in the Microsoft.SharePoint.Publishing assembly.  This class parses an XML file and builds the site heirarchy defined in the file. 

For example, consider an organization that wants to allow internal development teams to create a normal team collaboration site that also includes a team blog as well as a reporting site to show their progress and metrics.  Using a portal site definition, all three sites can be created as one "team portal".

Here are the steps to creating a Portal Site Definition.

1.        Create a WEBTEMP file containing the Portal Site Definition

You can name this file WEBTEMP*.xml or WEBTEMP.*.xml.  In it you define your custom site definitions including the portal site.   

<?xml version="1.0" encoding="utf-8"?>

<Templates xmlns:ows="Microsoft SharePoint">

       <Template Name="BSCBLog" ID="10001">

<Configuration ID="0" Title="BSC Blog" Hidden="FALSE" ImageUrl="/_layouts/images/blogprev.png"

Description="A Ballard Software Corporation site for a person or team to post ideas, observations, and expertise that site visitors can comment on."

              DisplayCategory="Ballard Software" >

              </Configuration>

       </Template>

       <Template Name="BSCTeam" ID="10007">

<Configuration ID="0" Title="BSC Team Site" Hidden="FALSE"  ImageUrl="/_layouts/images/stsprev.png"

Description="A site for teams to quickly organize, author, and share information. It provides a document library, and lists for managing announcements, calendar items, tasks, and discussions."

              DisplayCategory="Ballard Software" >

              </Configuration>

<Configuration ID="1" Title="BSC Blank Site" Hidden="FALSE" ImageUrl="/_layouts/images/blankprev.png"

Description="A blank site for you to customize based on your requirements."

              DisplayCategory="Ballard Software" AllowGlobalFeatureAssociations="False" >

              </Configuration>

       </Template>

       <Template Name="BSCReportCenter" ID="10010">

              <Configuration

                     ID="0"

                     Title="BSC Report Center"

Description="A site for creating, managing, and delivering Web pages, dashboards, and key performance indicators that communicate metrics, goals, and business intelligence information."

                     Type="0"

                     Hidden="FALSE"

                     ImageUrl="../images/rchome.png"

                     DisplayCategory="Ballard Software"

                     VisibilityFeatureDependency="A573867A-37CA-49dc-86B0-7D033A7ED2C8">

              </Configuration>

       </Template>

       <Template Name="BSCTeamPortal" ID="10008">

<Configuration ID="0" Title="BSC Team Site" Hidden="FALSE"

ImageUrl="/_layouts/1033/images/IPPT.gif"

Description="A Ballard Software Team Portal including a Team Site, Team Blog, and Reporting Center"

ProvisionAssembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"              ProvisionClass="Microsoft.SharePoint.Publishing.PortalProvisioningProvider"

                     ProvisionData="xml\\BSCPortal.xml"

                     DisplayCategory="Ballard Software"

              </Configuration>

       </Template>

</Templates>

The top 3 site templates define the sites that will be used by my Team Portal Site.  For more information on creating custom site definitions, see Todd Baginski's "How To" blog post.  The last template is the Portal Site Definition.  Notice that it specifically references the PortalProvisioningProvider using the ProvisionAssembly and ProvisionClass elements.  The ProvisionData element is a reference to the file that will be used as input to the provisioning process listing the webs that should be created.

2.        Create the Portal.xml file.

This is an XML file used to specify the sites to be created as part of the portal.  The listing below shows the BSC Team Portal specification.

<?xml version="1.0" encoding="utf-8"?>

<portal xmlns="PortalTemplate.xsd">

       <web name="TeamHome"

        siteDefinition="BSCTeam#0"

        displayName="$Resources:cmscore,IPPT_Portal_Root_DisplayName;"

        description="$Resources:cmscore,IPPT_Portal_Root_Description;" >

              <webs>

                     <web name="TeamBlog"

              siteDefinition="BSCBlog"

              displayName="Team Blog"

              description="" />

                     <web name="Reports"

              siteDefinition="BSCReportCenter"

              displayName="Team Report Center"

              description="" />

              </webs>

       </web>

</portal>

Notice that the template specified for the “Home” web is a combination of template ID and configuration # from my original WEBTEMP file.  The provisioning process is also recursive so you could define subsites as many levels deep as necessary.

After these files are created you simply need to reset IIS and the new portal will be available to your users.

You can also create your own Provisioning Provider by creating a class that inherits from Microsoft.SharePoint.SPWebProvisioningProvider and then overriding the Provision(SPWebProvisioningProperties) method.  Internally you would then use the SharePoint object model to add the webs via Web.Add().

 

No Comments