As a SharePoint Developer, often I am tasked with creating SharePoint
Templates for sub areas. The clients would like to use these templates
throughout the sub areas. At times the client requirements for SharePoint
Templates can be as easy as creating only some extra Web Part Zones or even
adding Web Part Zones to the header for images to be posted at a later stage.
But sometimes, the clients might ask for some challenging templates to display
multiple document libraries on the same page with default field names
displayed. This article will try to clarify some of the concepts of how the SharePoint
templates work.
With the help of this article, you will learn how to
1. Create a new template.
2. Add Web Part Zones to a template in default.aspx page.
3. Add Web Parts by default while create Sub Area Pages
using Onet.xml.
4. Create default Content Lists using Onet.xml.
5. Create multiple lists of the same list type in Onet.xml.
6. Change the view using Schema.xml.
Folder Structure
Let's look at the folder structure and the key elements of a
template. All the folders and files for SharePoint are located under C:\Program
Files\Common Files\Microsoft Shared\web server extensions\60.
The templates for SharePoint are stored under C:\Program
Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\1033.
Please note that all the folders related to SharePoint start
with SPS. The folder that starts with STS is for Windows SharePoint Services
(WSS). The differences between SharePoint Portal and WSS are beyond the scope
of this article.
The template information is stored under these folders. The explanation
of the elements under this folder will be explained later. There is one more
folder called xml folder. This folder contains various xml files. But the main
important xml file which ties all the elements together is WEBTEMPSPS.xml. This
file has all the information that relates the template to its respective folder.
If you open this file you will notice the following.
WEBTEMPSPS.xml
<Template Name="SPSTOC"
ID="30">
<Configuration ID="0"
Title="Contents area Template" Type="0"
Hidden="TRUE"
ImageUrl="../images/spshome.gif"
Description="Area Template.">
<!--
_locID@Title="webtemp_title_spstoc0"
_locComment="{StringCategory=HTX}"
-->
<!--
_locID@Description="webtemp_desc_spstoc0"
_locComment="{StringCategory=HTX}"
-->
</Configuration>
</Template>
The Name attribute in the Template represents the folder
name. In the above code, SPSTOC is the folder under which you will find all
the files related to the Contents Area Template.
So, when you assign a template to be used on the Sub Area in
the following screen, the dropdown list box is populating information from this
XML file.
Figure 1

FYI: SharePoint will pull information regarding templates
from the xml files starting with WEBTEMPSPS*.xml.
Once SharePoint is aware of all the templates that are installed
on your server, it has all the necessary information regarding the folders to be
used to design the template page. For example, if you have selected Contents
Area Template then it is aware that the template is pointing to SPSTOC folder.
The SPSTOC folder has the following folders.
DOCTEMP - This folder stores the file templates to be used
for Document Library Templates.
LISTS - The default lists provided by SharePoint.
XML - The XML files that are used to design the pages.
Detailed explanation of each and every folder is beyond the
scope of this article. But, when we start looking at building our own template,
I will highlight some files under these folders.
The default.aspx page is the page which will be displayed when
some sub area is created using this template.
Under XML folder, you will notice that there is one file
called Onet.xml. Onet.xml file will assist SharePoint with building the
default.aspx page and the contents list initially. We will look into the
Onet.xml file when we are building the template example.