Creating Custom Site Definitions

Creating Custom Site Definitions

Each front end Web Server in a Windows SharePoint Server solution contains at least one Webtemp.xml file that is by default located in the c: Program FilesCommon FilesMicrosoft Sharedweb server extensions60TEMPLATE1033XML folder. This file is used to store the site definitions that are available within the Template Selection page used for site creation as shown below in Figure 1. In this example I will create a new Site Definition for the Engineering team that is based on the existing Team Site definition.

Figure 1: The Template Selection Page

The Webtemp.xml file is an XML based configuration file that contains the list of items and attributes used to create sites. Each item stored in the file shown below matches an item that appears in the template list of Figure 1.

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

<!-- _lcid="1033" _version="11.0.5510" _dal="1" -->

<!-- _LocalBinding -->

<Templates xmlns:ows="Microsoft SharePoint">

<Template Name="STS" ID="1">

<Configuration ID="0" Title="Team Site" Hidden="FALSE" ImageUrl="/_layouts/images/stsprev.png" Description="This template creates a site for teams to create, organize, and share information quickly and easily. It includes a Document Library, and basic lists such as Announcements, Events, Contacts, and Quick Links."> </Configuration>

<Configuration ID="1" Title="Blank Site" Hidden="FALSE" ImageUrl="/_layouts/images/stsprev.png" Description="This template creates a Windows SharePoint Services-enabled Web site with a blank home page. You can use a Windows SharePoint Services-compatible Web page editor to add interactive lists or any other Windows SharePoint Services features."> </Configuration>

<Configuration ID="2" Title="Document Workspace" Hidden="FALSE" ImageUrl="/_layouts/images/dwsprev.png" Description="This template creates a site for colleagues to work together on documents. It provides a document library for storing the primary document and supporting files, a Task list for assigning to-do items, and a Links list for resources related to the document."> </Configuration>

</Template>

<Template Name="MPS" ID="2" >

<Configuration ID="0" Title="Basic Meeting Workspace" Hidden="FALSE" ImageUrl="/_layouts/images/mwsprev.png" Description="All the basics to plan, organize and track your meeting. This Meeting Workspace contains the following lists: Objectives, Attendees, Agenda, and Document Library."> </Configuration>

<Configuration ID="1" Title="Blank Meeting Workspace" Hidden="FALSE" ImageUrl="/_layouts/images/mwsprev.png" Description="A blank Meeting Workspace for you to customize based on your requirements."> </Configuration>

<Configuration ID="2" Title="Decision Meeting Workspace" Hidden="FALSE" ImageUrl="/_layouts/images/mwsprev.png" Description="A Meeting Workspace in which to review relevant documents and record decisions. This Meeting Workspace contains the following lists: Objectives, Attendees, Agenda, Document Library, Tasks, and Decisions."> </Configuration>

<Configuration ID="3" Title="Social Meeting Workspace" Hidden="FALSE" ImageUrl="/_layouts/images/mwsprev.png" Description="A planning tool for social occasions, featuring a discussion board and a picture library to post pictures of the event. This Meeting Workspace contains the following lists and Web Parts: Attendees, Directions, Image/Logo, Things To Bring, Discussions, and Picture Library."> </Configuration>

<Configuration ID="4" Title="Multipage Meeting Workspace" Hidden="FALSE" ImageUrl="/_layouts/images/mwsprev.png" Description="All the basics to plan, organize and track your meeting with multiple pages. This Meeting Workspace contains the following lists: Objectives, Attendees and Agenda in addition to two blank pages for you to customize based on your requirements."> </Configuration>

</Template>

</Templates>

Each of the XML elements of this file specifies the various descriptors that are needed to define a site template. The main Templates element specifies the configuration that are used to instantiate sites. Each of the individual Template elements specifies a unique ID and a name that corresponds to a site definition subfolder within the TEMPLATE1033 directory. A specific Template element can contain any number of Configuration sub-elements that specify a unique ID corresponding to the ID of a configuration contained in the ONET.XML file that specifies the lists and modules of a site definition. Additionally, each of the Configuration elements specifies the title, description and a virtual path to the preview image that is displayed on the Template Selection page.

 

Site definitions can also be marked as hidden, which will prevent it from appearing in the list of site types that a user can create. For example, if you have a customized version of the Team Site that should be used for generic site creation. The original Team Site Template can be hidden by modifying the hidden parameter to TRUE in the Webtemp.XML file.

 

All available site definition available for a server are stored in the Program FilesCommon FilesMicrosoft SharedWeb Server Extensions60TemplateLCIDXML, where LCID is a locale ID, such as 1033 for U.S. English.

Steps to Creating a Site Definition from an Existing Site Definition

A customized site definition can be created by copying and modifying an existing site definition. The following steps will show how to create a new Site definition for an Engineering Team Site that is based on the existing Team Site Definition.

  1. Copy the existing site definition folder location located in the C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions60Template1033STS directory to a new directory named ENGINEERING as shown below.

Before:

After:

Note: For reasons we will discuss shortly ALWAYS make sure that you name the new folder with all capital letters.

  1. Within the XML directory create a new file called WEBTEMPENGINEERING.XML. At run time the compiler will merge the information contained in this file with the information contained in the original WEBTEMP.XML file to specify which site templates are available for creating new sites

  1. Enter the following XML into the WEBTEMPENGINEERING file as follows to create the new site definition.

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

<Templates xmlns:ows="Microsoft SharePoint">

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

<Configuration ID="0" Title="Engineering Team Site" Type="0" Hidden="FALSE"

ImageUrl="/_layouts/images/stsprev.png" Description="This template provides a forum

for the engineering team to create, organize, and share information quickly and easily. It includes a

Document Library, and basic lists such as Announcements, Events, Contacts, and Quick Links.">

</Configuration>

</Template>

</Templates>

Each WEBTEMP.XML file contains a collection of Template elements and Configuration sub-elements, which identify to the compiler all the site definitions that can be instantiated. The Configuration elements define a title, a description, and a URL for the image displayed in the user interface, properties common to each Web Site created using the site definition.

 

It is important to make sure that each Template element defined in the WEBTEMP file contains the identical Name in all capital letters that is assigned to the new folder created above. Also, as a best practice when creating new templates to avoid conflicts with existing sites use a unique value that is greater than 10,000 for the ID attribute.

  1. Once the file is saved you will need to restart IIS for the new templates to appear on the Template Selection Page as shown below.