Tuesday, June 10, 2008

How to Creating a Custom Site Definition in Sharepoint

Site Definition project is a class library project.

All components that you want to be automatically provisioned within sites created from the site definition should be referenced from this ONET.xml file. The base structure of the ONET site definition schema is shown below.

NavBars
If you’d like to simply use the default navigation scheme in your site definition, copy the contents of this node from the STS site definition. If you are building custom navigation controls and want to bypass the SharePoint navigation user interface entirely, you can skip this node. Note that navigation bars included in this node also define the Quick Launch sidebar within the Team Site, which can also be accessed by code through the object model. To add a navigation element to the Quick Launch sidebar, add an additional NavBar element to the NavBars node. Following is an example QuickNav bar that you can add through CAML in the site definition. Note that the HTML within the Prefix, Body, and Suffix attributes is XML encoded. The name of the NavBar specifies the heading of the navigation section, and each NavBarLink node represents a hyperlink. NavBar Name="Site Pages"Prefix="<table border=0 cellpadding=4 cellspacing=0>"Body="<tr><td><table border=0 cellpadding=0 cellspacing=0><tr><td><img src='/_layouts/images/blank.gif' ID='100' alt='' border=0>&nbsp;</td><td valign=top><a ID=onetleftnavbar#LABEL_ID# href='#URL#'>#LABEL#</td></tr></table></td></tr>" Suffix="</table>"ID="1028" >NavBarLink Name="Web Page 1" Url="SitePages/Page01.aspx" />NavBarLink Name="Web Page 2" Url="SitePages/Page02.aspx" />NavBarLink Name="Web Page 4" Url="SitePages/Page04.aspx" />/NavBar>One more example

DocumentTemplates
The DocumentTemplates node documents are used as document library default documentswithin the site. If you do not provide document templates, the site is still created, but the user is not able to create new documents by using the New button in Document Libraries.
Configurations
The site definition can also have multiple configurations, but each configuration reuses the same modules,feature references, and lists. These named configurations must also be referenced in another configuration file, WEBTEMP.*.xml, to be available to Windows SharePoint Services.For example, the following List nodes specify that the Litware Customer Listand Litware Vendor List be created on site creation at the site-relative Lists/Vendors andLists/Customers URLs.

Within the configuration, you can also specify which features should be a part of this site collection or site. The SiteFeatures node lets you define features to be enabled for the site collection if the site is created as the site collection’s top-level site. For site features, you want to include common infrastructure such as the BasicWebParts feature, as well as any additional infrastructure such as a feature that installs your company’s custom .webpart Web Part entries in the Web Part gallery.SiteFeatures>Feature ID="00BFEA71-1C5E-4A24-B310-BA51C3EB7A57" />/SiteFeatures>WebFeatures>Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5" />/WebFeatures>
Modules
Module element is a defined file set with nested File elements that are used to provision pageinstances from page templates.

Web Template Files
The last component of the site definition is the WEBTEMP file. The WEBTEMP file referencesconfigurations in the site definition’s ONET.xml file. Each site definition solution youcreate should have its own WEBTEMP file, with the following naming convention:WEBTEMP.[solution].xml The WEBTEMP file has one Template node per site definitionand a Configuration node for each configuration.

No comments: