Friday, October 22, 2010

Site Definition in Microsoft SharePoint Server 2007

Following steps are included in creating a custom site definition:

  • Create a folder named “mySiteDef” at C:Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Site Templates\ 
  • Create a subfolder “XML” and create the onet.xml in it. The following kinds of tasks can be performed in a custom Onet.xml to create a custom site definition: 
    • Specify an alternate cascading style sheet (CSS) file, JavaScript file, or ASPX header file for a site definition.
    • Modify navigation areas for the home page and list pages
    • Add a list definition as an option to the Create page
    • Add a document template for creating document libraries
    • Define one or more configurations for the site definition, specifying the lists, modules, files, and Web Parts that are included when a site definition configuration is instantiated
  • It contains the following tags to define various items in a site definition. A sample onet.xml can be found at 12\TEMPLATE\SiteTemplates\SPS\XML folder in sharepoint farm (Same can be done through by copy existing site definition).
  • Within the “C:/Program Files/Common Files/Microsoft Shared/web server extensions/12/Templates/1033/XML” directory create a new file called webtempSiteMinder.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
  • Enter the following XML into the webtempSiteMinder file as follows to create the new site definition.
<?xml version="1.0" encoding="utf-8"?>
<!-- _lcid="1033" _version="12.0.4518" _dal="1" -->
<!-- _LocalBinding -->
<Templates xmlns:ows="Microsoft SharePoint">
<Template Name="MYSITEDEF" ID="325202">
<Configuration ID="1" Title="MYSITEDEF" Hidden="FALSE" ImageUrl="/_layouts/images/blogprev.png" Description="MYSITEDEF Subsite" DisplayCategory="Custom" > </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.
  • Once created the various site elements can be edited using Microsoft office sharepoint designer.