Installing Your Own Site Definition
The first step in customizing a site definition is to install it into SharePoint. You start this process by copying an existing site definition and placing it into another directory. You can use any of the existing site definitions as your starting point. For demonstration purposes, copy the STS site definition folder structure to a new
DEVX folder. Doing that gives you a new site definition based on the contents of the
DEVX directory.
Next, connect the DEVX site definition to SharePoint by copying the
WEBTEMP.XML file located in the
TEMPLATE\<LCID>\XML directory to a file named
WEBTEMPDEVX.XML. Open the file and delete any unnecessary
<Template> tags. For this example, remove the
<Template> tag whose
Name attribute value is "MPS." Change the
Name attribute of the remaining
<Template> tag from
STS to
DEVX, and change the
ID attribute of the
<Template> tag so that it is uniquegenerally numbers above 10000 will be safe. Finally, modify each of the
Title attributes of the configuration tags so that you can easily determine which site definitions the file contains. The resulting
WEBTEMPDEVX.XML file should look something like
Listing 2.
The final step is to perform an IIS reset so that SharePoint "sees" the new site definition. After restarting IIS you can create a new site and see your new site definitions. Note that your new site will look exactly like an out-of-the-box Windows SharePoint Services site.
Customizing Your Site Definition
Now that you have your own site definition to work from you can customize it to meet your needs. Most people make two basic customizations. First, they customize the
ONET.XML file to control how SharePoint creates new sites. Second, they change the
.aspx pages to reflect other visual changes. You can make these latter changes at any time, but changes to the
ONET.XML file affect only the creation of new sites, and are therefore of limited use after you've already created many sites.
Customizing ONET.XML
One of the most difficult customizations for most people seems to be adding a Web Part to a page. Earlier, I mentioned that the
Configurations section of the
ONET.XML file matches the configuration options in the
WEBTEMP*.XML file. The
ONET.XML contains a section for configuration 0the default. This section creates several lists and then performs the actions listed in two modules. The first module, named
Default, adds the
default.aspx page. The second adds some Web Parts to the Web Part libraryfor this customization, you can ignore the second module.
 | |
| Figure 1. The DEVX Default Template: This shows how a new site built on the modified DEVX Default template looks when you browse to its default.aspx page. |
The
Default module appears below the configuration section in the modules section and includes the appropriate reference for
default.aspx as well as the lists to add to that file (page). The process of adding a new list view Web Part to the page is as simple as adding a new
View tag. The
List attribute in the
View tag must match the
ID tag from the
<list> tag in the
<configuration> tag from above. You should set the Web Part order so that the Web Part appears in the correct location relative to the other Web Parts in the Web Part zone that you specify. So, to add a new Web Part on the page that displays the task list, the
View tag would look like this:
<View List="107" BaseViewID="0"
WebPartZoneID="Left" WebPartOrder="3"/>
The
107 used in the
List attribute matches the Tasks List item from the configuration. A quick IIS reset and you can create a new site based on your revised settings. If you made the changes above and created a new
DEVX team site, the tasks list would appear on the
default.aspx page under the events as shown in
Figure 1.