An organization may require multiple site templates designed for each department or team. Each template may contain it’s own navigation, libraries and features associated with them. To build such templates we normally tend to create multiple site definitions.
But that’s not the best approach to fulfill the requirement. Instead of multiple site definitions, we can create multiple configuration items within the same site definition.
Following scenario shows the onet.xml file of a site definition which contains two configurations created for HR department and Finance department.
Given below is the configuration section for ContosoHR which contains custom lists and some features
- <Configuration ID="0" Name="ContosoHR">
- <Lists>
- <List
- FeatureId="00BFEA71-E717-4E80-AA17-D0C71B360101"
- Type="101"
- Title="HR Documents"
- Url="$Resources:core,shareddocuments_Folder;"
- QuickLaunchUrl="$Resources:core,shareddocuments_Folder;/Forms/AllItems.aspx" />
- </Lists>
- <SiteFeatures>
- <!-- BasicWebParts Feature -->
- <Feature ID="00BFEA71-1C5E-4A24-B310-BA51C3EB7A57" />
- <!-- Three-state Workflow Feature -->
- <Feature ID="FDE5D850-671E-4143-950A-87B473922DC7" />
- </SiteFeatures>
- <WebFeatures>
- <!-- TeamCollab Feature -->
- <Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5" />
- <!-- MobilityRedirect -->
- <Feature ID="F41CC668-37E5-4743-B4A8-74D1DB3FD8A4" />
- <!-- WikiPageHomePage Feature -->
- <Feature ID="00BFEA71-D8FE-4FEC-8DAD-01C19A6E4053" />
- </WebFeatures>
- <Modules>
- <Module Name="DefaultBlank" />
- </Modules>
- </Configuration>
Then we need to modify the web template file (webTemp_ContosoSites.xml file in this example) to include our custom configurations.
- <?xml version="1.0" encoding="utf-8"?>
- <Templates xmlns:ows="Microsoft SharePoint">
- <Template Name="ContosoSites" ID="10002">
- <Configuration ID="0"
- Title="Contoso HR Site"
- Hidden="FALSE"
- ImageUrl="/_layouts/images/CPVW.gif"
- Description="Contoso HR Site"
- DisplayCategory="Contoso Sites">
- </Configuration>
- <Configuration ID="1"
- Title="Contoso Finance Site"
- Hidden="FALSE"
- ImageUrl="/_layouts/images/CPVW.gif"
- Description="Contoso HR Site"
- DisplayCategory="Contoso Sites">
- </Configuration>
- </Template>
- </Templates>
After deploying the site definition, we can see multiple templates available under “Contoso Sites” section
By doing this we can properly group our site templates. Furthermore this is the way how SharePoint groups it’s default site templates (e.g.: Team Site, Blank Site, etc..)