Understanding SharePoint Site Definitions
Today I wanted to share how to create site definition in SharePoint 2010 and how to create onet.xml The process to create a custom site definition has not changed much from WSS3.0/MOSS 2007, the only differences are the directory names and some of the XML in the WEBTEMP files.
Site definitions are located in the following folder on the SharePoint server:
C:\Program Files\Common Files\Microsoft Shared\web server
extensions\14\TEMPLATE\SiteTemplates
Each site definition has its own sub directory under this folder.
Inside each site definition sub directory the .aspx pages for the various web pages and lists that make up the site definition are stored. Some of the new site definitions that come with SharePoint 2010 also include image files in these subdirectories , Good part of this is you images will be unghostable now So no more dependency on layouts folder. The ONET.XML file has similar meaning as in wss 3.0 and it specifies the Various settings and modules. It is stored inside the XML subdirectory inside each site definition sub directory.
Site definitions are registered with SharePoint and made available via the WEBTEMP.XML file. Although you can register a site definition with any of the existing webtemp xml files but its advisable and a best pra

Creating a custom Site Definition in SharePoint 2010 – Visual Studio 2010 Approach
Visual Studio 2010 simplifies the process by providing a project type specifically tailored for this purpose. To create a custom site definition with Visual Studio 2010 first create a new Site Definition project. See the screenshot below for reference.

Then set the path to the SharePoint site where you would like to deploy the site definition.

Once the project is created, you can see all the files needed to support a custom site definition in the Solution Explorer.

One of the most important thing in this structure is onet.xml
Onet.xmp starts with
Project tag
The Project element does not contain any attribute that identifies the site definition that it defines. Each Onet.xml file is associated with a site definition by virtue of the directory path in where it resides, which (except for the global Onet.xml) is %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\SiteTemplates\site_type\XML\, where site_type is the name of the site definition, such as STS or MPS. The Onet.xml file for a web template is associated with the template by virtue of being in the .wsp package for the web template.
Revision="2"
ListDir="$Resources:core,lists_Folder;"
xmlns:ows="Microsoft SharePoint"
UIVersion="4">
First Tag in Project Tag is
NavBars
The NavBars element contains definitions for the top navigation area that is displayed on the home page or in list views, and definitions for the side navigation area that is displayed on the home page.
Separator=" "
Body="<a ID='onettopnavbar#LABEL_ID#' href='#URL#' accesskey='J'>#LABEL#</a>"
ID="1002" />
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'> </td><td valign='top'><a id='onetleftnavbar#LABEL_ID#' href='#URL#'>#LABEL#</td></tr></table></td></tr>"
Suffix="</table>"
ID="1004" />
...
After NavBars next element is
ListTemplates
The ListTemplates section specifies the list definitions that are part of a site definition. This markup is still supported only for backward compatibility. New custom list types should be defined as Features. The following example is taken from the Onet.xml file for the Meetings Workspace site definition.
DisplayName="$Resources:xml_onet_mwsidmeetingDisp;"
Type="200"
BaseType="0"
Unique="TRUE"
Hidden="TRUE"
HiddenList="TRUE"
DontSaveInTemplate="TRUE"
SecurityBits="11"
Description="$Resources:xml_onet_mwsidmeetingDesc;"
Image="/_layouts/images/itevent.gif">
DisplayName="$Resources:xml_onet_mwsidagendaDisp;"
Type="201"
BaseType="0"
FolderCreation="FALSE"
DisallowContentTypes="TRUE"
SecurityBits="11"
Description="$Resources:xml_onet_mwsidagendaDesc"
Image="/_layouts/images/itagnda.gif">
...
Each ListTemplate element specifies an internal name that identifies the list definition. The ListTemplate element also specifies a display name for the list definition and whether the option to add a link on the Quick Launch bar appears selected by default in the list-creation UI. In addition, this element specifies the description of the list definition and the path to the image that represents the list definition, both of which are displayed in the list-creation UI. If Hidden="TRUE" is specified, the list definition does not appear as an option in the list-creation UI.
The ListTemplate element has two attributes for type: Type and BaseType. The Type attribute specifies a unique identifier for the list definition, and the BaseType attribute identifies the base list type for the list definition and corresponds to the Type value that is specified for one of the base list types that are defined in the global Onet.xml file.
After List Templates comes
DocumentTemplates
he DocumentTemplates section defines the document templates that are listed in the UI for creating a document library. This markup is still supported only for backward compatibility. You should define new document types as content types. For more information, see the Content Types section of this SDK.
...
DisplayName="$Resources:core,doctemp_Word;"
Type="121"
Default="TRUE"
Description="$Resources:core,doctemp_Word_Desc;">
TargetName="Forms/template.dotx"
Default="TRUE" />
...
Each DocumentTemplate element specifies a display name, a unique identifier, and a description for the document template. If Default is set to TRUE, the template is the default template selected for document libraries that are created in sites based one of the configurations in the site definition. Despite its singular name, a DocumentTemplate element actually can contain a collection of DocumentTemplateFile elements. The Name attribute of each DocumentTemplateFile element specifies the relative path to a local file that serves as the template. The TargetName attribute specifies the destination URL of the template file when a document library is created. The Default attribute specifies whether the file is the default template file.
BaseTypes Element
The BaseTypes element of the global Onet.xml file is used during site or list creation to define the basic list types on which all list definitions in SharePoint Foundation are based. Each list template that is specified in the list templates section is identified with one of the base types: Generic List, Document Library, Discussion Forum, Vote or Survey, or Issues List.
Image="/_layouts/images/itgen.gif"
Type="0">
ColName="tp_ID"
RowOrdinal="0"
ReadOnly="TRUE"
Type="Counter"
Name="ID"
PrimaryKey="TRUE"
DisplayName="$Resources:core,ID"
SourceID="http://schemas.microsoft.com/sharepoint/v3"
StaticName="ID">
RowOrdinal="0"
Type="ContentTypeId"
Sealed="TRUE"
ReadOnly="TRUE"
Hidden="TRUE"
DisplayName="$Resources:core,Content_Type_ID;"
Name="ContentTypeId"
DisplaceOnUpgrade="TRUE"
SourceID="http://schemas.microsoft.com/sharepoint/v3"
StaticName="ContentTypeId"
ColName="tp_ContentTypeId">
...
...
Each BaseType element specifies the fields used in lists that are derived from the base type. The Type attribute of each Field element identifies the field with a field type that is defined in FldTypes.xml.
Configurations
Each Configuration element in the Configurations section specifies the lists, modules, and Features that are created by default when the site definition configuration or web template is instantiated.
...
Name="Default">
- FeatureId="00BFEA71-E717-4E80-AA17-D0C71B360101"
Type="101"
Title="$Resources:core,shareddocuments_Title;"
Url="$Resources:core,shareddocuments_Folder;"
QuickLaunchUrl="$Resources:core,shareddocuments_Folder;/Forms/AllItems.aspx" />
...
...
The ID attribute identifies the configuration (uniquely, relative to the other configurations, if any, within the Configurations element). If the Onet.xml file is part of a site definition, the ID value corresponds to the ID attribute of a Configuration element in a WebTemp*.xml file. (Web templates do not have WebTemp*.xml files.)
Each List element specifies the title of the list definition and the URL for where to create the list. You can use the QuickLaunchUrl attribute to set the URL of the view page to use when adding a link in the Quick Launch to a list that is created from the list definition. The value of the Type attribute corresponds to the Type attribute of a template in the list templates section. Each Module element specifies the name of a module that is defined in the modules section.
The SiteFeatures element and the WebFeatures element contain references to site collection and site-scoped Features to include in the site definition.
For post-processing capabilities, use an ExecuteUrl element within a Configuration element to specify the URL that is called following instantiation of the site.
Modules
The Modules collection specifies a pool of modules. Any module in the pool can be referenced by a configuration if the module should be included in websites that are created from the configuration. Each Module element in turn specifies one or more files to include, often for Web Parts, which are cached in memory on the front-end web server along with the schema files. You can use the Url attribute of the Module element to provision a folder as part of the site definition. This markup is supported only for backward compatibility. New modules should be incorporated into Features.
Url=""
Path="">
NavBarHome="True">
/$Resources:core,announce_Folder;"
BaseViewID="0"
WebPartZoneID="Left" />
/$Resources:core,calendar_Folder;"
BaseViewID="0"
RecurrenceRowset="TRUE"
WebPartZoneID="Left"
WebPartOrder="2" />
WebPartOrder="1">
Comments
Post a Comment