Tuesday, November 3, 2009

Include Web Parts in Custom Site Definition through ONET.xml

When you install Windows SharePoint Services 3.0, six Onet.xml files are placed within the setup directory, one in \Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\GLOBAL\XML that applies globally to the deployment, and five in different folders within ...\TEMPLATE\SiteTemplates that apply to each of the five site definitions that ship with Windows SharePoint Services 3.0. They are Blog sites, the central administration site, Wiki sites, Meeting Workspace sites, and team SharePoint sites.

The global Onet.xml file defines list templates for hidden lists, list base types, a default definition configuration, and modules that apply globally to the deployment. The five Onet.xml files in the \SiteTemplates directory define navigational areas, list templates, document templates, configurations, modules, components, and server e-mail footer sections used in the five site definitions.

Functions of Onet.xml

Depending on its particular use, an Onet.xml file can serve multiple functions, such as the following:

  • Define the top and side navigation areas that appear on the home page and in list views for a site definition.
  • Specify the list definitions that are used in each site definition and whether they are available for creating lists on the Create page.
  • Specify document templates that are available in the site definition for creating document library lists on the New page, and specify the files used in the document templates.
  • Define the base list types from which default Windows SharePoint Services lists are derived. (Only the global Onet.xml file serves this function.)
  • Specify the configurations of lists and modules that are used within each site definition.
  • Specify Windows SharePoint Services components.
  • Define the footer section used in server e-mail.

Web Site Definition Tasks with Onet.xml

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.

Include web parts in ONET.xml

We can include web parts in ONET.xml so that they are available on default page of the site when created with site template.

I am not going in detail about different sections of ONET file. Assuming you are aware of this. J . You can always get back to me on this.

First I’ll discuss about how to put a OOTB web part such as shared documents, Announcements, etc. on home page. Here I am discussion about how to put shared documents web part.

· You need to include feature ID of shared documents in ONET file in <Lists> section which will be activated upon creation of site collection and list will get created. You need not change feature ID of shared documents. You can check it from 12 hive\TEMPLATE\FEATURES\DocumentLibrary\Feature.xml.

· Put the following line under Lists section of configuration ID 0

· <List 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" />

· It should be as below.

<Configurations>

<Configuration ID="-1" Name="NewWeb" />

<Configuration ID="0" Name="Default">

<Lists>

<List 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" />

· Now put below line under Module. Here we can mention where the web part should be placed and the order.

· <View List="$Resources:core,shareddocuments_Folder;" BaseViewID="0"

WebPartZoneID="Left"

WebPartOrder="2" />

· It should be as below

<Modules>

<Module Name="Default" Url="" Path="">

<File Url="default.aspx" NavBarHome="True">

<View List="$Resources:core,shareddocuments_Folder;" BaseViewID="0"

WebPartZoneID="Left"

WebPartOrder="2" />

That’s it. Create site collection with custom site template. You should be able to see Shared Documents web part in Left zone on top.

No comments:

Post a Comment