Tuesday, May 8, 2007

Creating New Site Definition Using CAML

This post is going to center around creating a new site definition. This is the first in a series of posts centered around Site Definition CAML Modification

Let's begin:

  1. We are first going to Copy the existing Definition following the instructions outlined in: http://msdn2.microsoft.com/en-us/library/ms454677.aspx
  2. Copy the existing site definition folder located in the Local_Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates\sts directory.

For example, to create a custom site definition that derives from the site definition for Microsoft Windows SharePoint Services, copy the sts folder. You can give the folder any name that contains no spaces.

  1. Make a copy of the WebTemp.xml file that is located in Local_Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML.

Give the file a unique name by appending a string to the name of the original file; for example, WebTempAction.xml. At run time, the compiler merges information contained in this file with the information contained in the original file to specify which site templates are available for creating new sites.

  1. Customize the contents of the new WebTemp file.

Each WebTemp.xml file contains a collection of Template elements and Configuration subelements, which identify to the compiler all the site definitions that can be instantiated. The Configuration element defines, for example, a title, a description, the URL for the image displayed in the user interface (UI), and a display category that specifies the tab on which to display the template in the Template Selection section of the New SharePoint Site page. These properties are common to each Web site created through the site definition.

Important:

In each Template element defined in the WebTemp file, the Name attribute must contain the same name that is assigned to the new folder. Also, to avoid conflict with IDs already used in Windows SharePoint Services, use unique values greater than 10,000 for the ID attribute.

Example

The following example defines a single site definition. The example assumes the existence of an ActionCommittee directory that has been created as previously described.

Copy Code

<?xml version="1.0" encoding="utf-8" ?> <Templates xmlns:ows="Microsoft SharePoint"> <Template Name=" ActionCommittee " ID="10001"> <Configuration ID="0" Title="Action Committee Team Site" Hidden="FALSE" ImageUrl="images/stsprev.jpg" Description="This template provides a forum for the 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." DisplayCategory="Collaboration"> </Configuration> </Template> </Templates>

You may need to reset Internet Information Services (IIS) to cause the new template to appear as an option in the UI.

The next post on this topic will focus on adding the publishing features to the site and creating custom web pages on site creation. The one following that will center around user permissions on lists and how to modify within the CAML.

1 comment:

Joseph Krupinski said...

The following is also a wonderful article on Best Practices of Site Definition Creation: http://dotnet.sys-con.com/read/48162.htm