Creating Duet Enterprise Site Definitions
Site definitions offer developers an easy way to create templates that form the basis for new sites.
Applies to: Duet Enterprise for Microsoft SharePoint and SAP Server 2.0 | Office 2010 | SharePoint Server 2010
Duet Enterprise provides the following site definitions: Customer and Product. Duet Enterprise site definitions are located on the server that is running Microsoft SharePoint Server 2010 in the path c:\Program Files\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\SiteTemplates. Each site definition has its own subdirectory under the SiteTemplates directory. You can use these site definitions as the basis for creating custom site definitions.
Note
Modifying a built-in Duet Enterprise or SharePoint site definition is not supported.
Site definition files are cached in memory on the server when you first access them. This improves scalability and performance by reducing unnecessary data storage or retrieval, and by enabling uncustomized pages to be reused across sites. The information contained in these files is pulled from the cache for each subsequent request.
Creating Custom Site Definitions for Duet Enterprise
To create a custom site definition, you must add Collaborative Application Markup Language (CAML) markup to two critical files: WebTemp*.xml and Onet.xml. In some scenarios, you also might have to create one or more custom site pages. To ensure that your custom site type is ready for globalization, you can also use one or more resource files.
Modifying a built-in SharePoint site definition is not supported. If you need a new kind of site, you must create a new WebTemp*.xml file and a new Onet.xml file. However, you can create many sections of a custom Onet.xml file by copying the corresponding section from the Onet.xml file of one of the built-in site definitions.
When site pages are customized—excluding browser-based customizations such as modifications to Web Parts—the pages and their contents are stored in the content database. Any .aspx files that you upload are also stored in the content database. The contents of customized pages are evaluated by using safe mode parsing, which helps prevent unsafe server-side code from executing. Safe mode parsing depends on the Safe Controls list. The Safe Controls list contains the names of controls and Web Parts, specific to your SharePoint site, that server administrators can designate as safe for invocation on any .aspx page within a site. This list is part of the web.config file in the top-level folder of your web application.
You can create site definitions declaratively or by creating a Visual Studio 2010 site definition project.
Creating SharePoint WebTemp*.xml Files
The WebTemp*.xml files contain an itemization of the site definition configurations that are available to a user for selection in the user interface (UI) when the user is creating a SharePoint site.
WebTemp*.xml files are located on the server that is running SharePoint in the path c:\Program Files\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\1033\XML.
Site definitions are registered with SharePoint and made available via the WebTempNameOfSiteDefinition.xml file. Although you can register a site definition with SharePoint by using one of the built-in WebTemp*.xml files, this can introduce problems when service packs or newer versions of the product are released. It is a best practice to create your own WebTemp*.xml file to register your custom site definitions.
For more information about customizing WebTemp*.xml files, see Understanding WebTemp*.xml Files (https://msdn.microsoft.com/en-us/library/ms447717.aspx).
Performing Web Site Definition Tasks with Custom Onet.xml Files
The Onet.xml file specifies the various configurations and modules that make up the site definition. This file is stored in the XML subdirectory inside each site definition directory.
You can perform the following tasks in a custom Onet.xml file:
Specify an alternate cascading style sheet (.css) file, ECMAScript (JavaScript, JScript) file, or .aspx header file for a site definition.
Modify navigation areas for the home page and list pages.
Add a new list definition as an option in the UI.
Define one configuration for the site definition or web template, specifying the lists, modules, files, and Web Parts that are included when the configuration is instantiated.
Specify Features to be included automatically with websites that are created from the site definition or web template.
Best Practices for Creating Site Definitions for Duet Enterprise Solutions
Always make your changes in a custom site definition instead of in the built-in site definition. If you work from files within a copied, uniquely named site definition directory, your customizations will not be overwritten when software updates, upgrades, or security updates are applied to the deployment, and your custom code will remain reusable. Of course, to perform certain programming tasks, you must modify original files in the setup directory. Be aware that originally installed files are overwritten during an upgrade; customizations that you make to these files will be lost.
If you always save copies of original files that you have customized, you can transfer your code into the new files after the update or upgrade is complete. Depending on the specific changes that are implemented in an update, you may not be able to simply replace the originally installed files; you might have to merge your changes into the updated product files. It is a best practice to keep detailed notes as to what specific changes you make to these files, so that if they are replaced during an update, you can more easily merge changes.
Declaratively Creating a Duet Enterprise Site Definition
You can create a site definition for Duet Enterprise without using Visual Studio 2010. After you create the necessary files, place them into the correct directories. To create a site definition without using Visual Studio 2010, follow these steps:
To create a site definition without using Visual Studio 2010
Create a WebTemp*.xml file.
Create a Onet.xml file.
Modify the site's pages.
Restart Internet Information Services (IIS).
Create a new site that is based on your custom site definition.
To create a site definition that is based on an existing site definition
Navigate to the following directory on the SharePoint server:
c:\Program Files\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\SiteTemplates
Create a copy of the STS directory in the SiteTemplates directory. (You can copy any of the existing site definitions and use them as starting points to create your own site definitions.)
Rename the copy of the STS directory with a name that you choose.
To create the WebTemp*.xml file to register the site definition with SharePoint
Create a file named WebTempSample.xml in the following directory:
c:\Program Files\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\1033\XML
Copy the following XML into the WebTempSample.xml file.
<?xml version="1.0" encoding="utf-8"?> <!-- _lcid="1033" _version="14.0.4514" _dal="1" --> <!-- _LocalBinding --> <Templates xmlns:ows="Microsoft SharePoint"> <Template Name="SAMPLE" ID="10001"> <Configuration ID="0" Title="Sample Team Site" Hidden="FALSE" ImageUrl="/_layouts/images/stts.png" Description="A sample team site." DisplayCategory="Custom Site Definitions" > </Configuration> <Configuration ID="1" Title="Sample Blank Site" Hidden="FALSE" ImageUrl="/_layouts/images/stbs.png" Description="A sample blank site." DisplayCategory="Custom Site Definitions" AllowGlobalFeatureAssociations="False" > </Configuration> <Configuration ID="2" Title="Sample Document Workspace" Hidden="FALSE" ImageUrl="/_layouts/images/stdw.png" Description="A sample document workspace." DisplayCategory="Custom Site Definitions" > </Configuration> </Template> </Templates>Note
The DisplayCategory attribute of the Configuration element determines which tab the configuration appears on in the Create New Site dialog box. You can create your own tabs by changing the values in this attribute. In the example XML, the configuration appears on a tab named Custom Site Definitions.
Restart IIS to load the new site definitions, and then create a new site based on your site definition.
To reset IIS
Click Start, click All Programs, and then click Accessories.
Right-click Command Prompt, and then click Run as administrator to open a Command Prompt window with administrator privileges on the server that is running SharePoint Server 2010.
In the Command Prompt window, at the prompt, type iisreset.
Creating a Duet Enterprise Site Definition Using Visual Studio 2010
By using Visual Studio 2010, you can create site definitions more quickly. The following procedure describes the high-level tasks required to create a Duet Enterprise site definition.
To create a Duet Enterprise site definition by using Visual Studio 2010
Create a Visual Studio 2010 Site Definition project.
Modify the WebTemp*.xml file.
Modify the Onet.xml file.
Modify the site's pages.
Deploy and test the site definition.
For more information and detailed steps, see How to: Create a Custom Site Definition and Configuration (https://msdn.microsoft.com/en-us/library/ms454677.aspx).
See Also
Concepts
How To: Create a Workspace Instance Site Using Visual Studio 2010