There were three main reasons for creating the Site Configurator feature:
1. In some scenarios there is a need for being in as much control of the site provisioning process as possible; making sure what gets created in what order. 2. A wish to reuse as much custom functionality as possible. 3. Making site provisioning as easy as possible, because sometimes developers found it hard to use and understand the built-in provisioning mechanisms.
1. In some scenarios there is a need for being in as much control of the site provisioning process as possible; making sure what gets created in what order.
2. A wish to reuse as much custom functionality as possible.
3. Making site provisioning as easy as possible, because sometimes developers found it hard to use and understand the built-in provisioning mechanisms.
The term provisioning is used to describe the process of creating a new SharePoint site and making it available for end-users. There are several steps in the creation process and SharePoint provisions in the following order:
This is a fairly complex process and it can often be hard to know the method for customizing a site definition. A solution can be right in one scenario and completely wrong in another, making this somewhat confusing.
If you want to catch up on site definitions or other parts of this process take a look at the following links, Site definitions and configurations and How to: Create a Custom Site Definition and Configuration.
Site Configurator is attaching to step 5, as a web stapled feature, as late in the out-of-the-box (OOB) provisioning as possible. Omitting steps 2, 3 and 4 is also recommended and will be the case if you use the blank site definition template as a starting point.
Once the Site Configurator is activated, it reads a siteconfigurations.xml file from its feature folder. The file consists of configuration elements, ie. custom settings, web parts, list instances, other features to activate, and then configures your site according to the specifications.
In order to make Site Configurator handle customization of your site, you need to complete three steps with an optional fourth:
1. Create a Site Configurator feature 2. (Optional) Create a new site definition 3. Staple the Site Configurator feature to a site definition. 4. Deploy and create a new site.
1. Create a Site Configurator feature
2. (Optional) Create a new site definition
3. Staple the Site Configurator feature to a site definition.
4. Deploy and create a new site.
Make sure you generate and use your own IDs for the features you create!
The Site Configurator needs to be triggered to start making the configurations of your site. A feature receiver is used as this trigger. The feature simply points to the feature receiver in the “sharepointsiteconfigurator.dll”:
<?xml version="1.0" encoding="utf-8" ?> <Feature xmlns="http://schemas.microsoft.com/sharepoint/" ReceiverAssembly="SiteConfigurator, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4d009ee268a83a6d" ReceiverClass="SharePointSiteConfigurator.SiteConfigurator_FeatureEventReceiver" Scope="Web"> <ElementManifests> <ElementFile Location="SiteConfigurations.xml" /> </ElementManifests> </Feature> Also, this feature must contain the “siteconfigurations.xml” file, which defines the configurations to apply. A minimal example: <?xml version="1.0" encoding="utf-8" ?> <SiteConfigurations xmlns="http://tempuri.org/siteconfigurator.xsd"> <SiteConfiguration Name="SITEDEFINITIONEXAMPLE#0"> <ApplyTheme Id="Simple"/> </SiteConfiguration> </SiteConfigurations>
<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
ReceiverAssembly="SiteConfigurator, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4d009ee268a83a6d"
ReceiverClass="SharePointSiteConfigurator.SiteConfigurator_FeatureEventReceiver" Scope="Web">
<ElementManifests> <ElementFile Location="SiteConfigurations.xml" /> </ElementManifests>
</Feature>
Also, this feature must contain the “siteconfigurations.xml” file, which defines the configurations to apply. A minimal example:
<SiteConfigurations xmlns="http://tempuri.org/siteconfigurator.xsd">
<SiteConfiguration Name="SITEDEFINITIONEXAMPLE#0">
<ApplyTheme Id="Simple"/>
</SiteConfiguration>
</SiteConfigurations>
This configuration will apply the theme “Simple” to a new site, if the site is made from the site definition “SITEDEFINITIONEXAMPLE” and configuration number “0” (“#0”)
Creating a new site definition is described on http://msdn.microsoft.com/en-us/library/ms454677(office.14).aspx
On the Codeplex site we’ve included a sample definition which you can use as a starting point, and this site definition is used as reference in this document.
This configuration will apply the theme “Simple” to a new site, if the site is made from the site definition “SITEDEFINITIONEXAMPLE” and configuration
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <!-- The feature will be stapled (activated) on all sitedefinitions you list here--> <FeatureSiteTemplateAssociation Id="499bb3bb-9363-4f3d-a96d-1d69948c2cf3" TemplateName="SiteDefinitionExample#0" /> </Elements> The ID provided here is the ID of the feature to staple, in this instance the ID of the Site Configurator feature created in step 1.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- The feature will be stapled (activated) on all sitedefinitions you list here-->
<FeatureSiteTemplateAssociation Id="499bb3bb-9363-4f3d-a96d-1d69948c2cf3" TemplateName="SiteDefinitionExample#0" />
</Elements>
The ID provided here is the ID of the feature to staple, in this instance the ID of the Site Configurator feature created in step 1.
In the solution available on the project site, a Site Configurator feature and a Farm Stapler are included. You should use these files as examples on how to set up your own solution.
After completing these steps, build your solutions in Visual Studio. This will create .wsp files. Either deploy them with use of Visual Studio, PowerShell or STSADM.exe. The deploy will copy the solution(s) to SharePoint and place the siteconfigurator.dll the GAC (Global Assembly Cache ie. c:\windows\assembly) and the features and their configuration files are deployed to the SharePoint 14 catalog (14 hive).
Creating a new site of the type specified in step 3, will now trigger the Site Configurator and configure the site according to the specifications in the siteconfigurations.xml file.
For more information go to the SharePoint Site Configurator site.