Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

SharePoint 2010 : Packaging and Deployment Model - Site Definitions

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
1/7/2013 3:45:40 PM
You’ve seen how we can package our customizations using features and solutions. By using these methods, we can activate and deactivate particular features to achieve our desired level of functionality. This process works well if we’re adding functionality to an existing site, but what happens if we want to create a new site that uses functionality that’s encapsulated in a number of features? As we did in an earlier example, we could start out with a blank site and enable the appropriate features. However, SharePoint provides a better way to achieve this result. We can create a custom site definition.

To understand how a custom site definition fits into the overall picture, select New Site from the Site Actions menu on any SharePoint site. Each of the items listed in the Create dialog is an example of a site definition. Basically, a site definition is a template that can be used to create new sites. By creating a custom site definition, we can specify how a new site is provisioned, including which features should be activated and which lists and libraries should be created by default.

Note

Regarding site definitions versus site templates, from SharePoint Designer, we can save a site as a site template. When using this function, we’re actually creating a WSP package that contains a list of customizations to whatever site definition the site was created from. This type of site template can then be applied to other sites that are derived from the same site definition. This functionality differs from that of creating a custom site definition because site definitions can be used only when creating new sites.


Confusingly, site definitions as stored on each front-end server in the %SPROOT%TEMPLATE\SiteTemplates folder. In a similar manner to features, each site definition has its own folder. The site definition configuration is stored in a file named onet.xml within the XML folder.

Site definitions have been part of SharePoint since day 1, whereas the feature framework was introduced in Windows SharePoint Services 3.0 to provide a higher degree of flexibility. As a result of this, site definitions come with some serious baggage and can be pretty complex. The recommended approach with SharePoint 2010 is to factor as much configuration into features as possible. This helps to keep site definition files maintainable while still allowing a high degree of flexibility.

Tip

When creating site definitions, bear in mind that future service packs for SharePoint may overwrite out-of-the-box files. Always create a separate folder for any customized site definitions. As you’ll see when using Visual Studio, this approach is adopted automatically.


Creating Site Definitions Using Visual Studio

Let’s look at how we can create a new site definition using Visual Studio.

  1. Choose File | Add | New Project.

  2. In the Add New Project dialog, select Site Definition and name the new project Example19DemoSite, as shown:

A new project is added containing the following files:

  • onet.xml Contains the site definition markup. Each onet.xml file can contain more than one configuration, where a configuration is for all intents and purposes a site definition.

  • webtemp-Example19DemoSite.xml The SharePoint platform builds a list of available templates by examining the %SPRoot%Template\1033\xml\ folder for XML files with names beginning with webtemp. These files act as a table of contents for the site definitions that are stored in each onet.xml file.

  • default.aspx As you’ll see when we look at the onet.xml file, the default.aspx file is deployed to the root of a new site that’s created using our custom site definition. Without this file, there would be no home page for the site.

If we examine the onet.xml file that’s been added to our project automatically, we’ll find the following XML:

     <Project Title="Example19DemoSite" Revision="2"
              ListDir="" xmlns:ows="Microsoft SharePoint"
              xmlns="http://schemas.microsoft.com/sharepoint/">
       <NavBars>
       </NavBars>
       <Configurations>
         <Configuration ID="0" Name="Example19DemoSite">
            <Lists/>
            <SiteFeatures>
            </SiteFeatures>
            <WebFeatures>
            </WebFeatures>
            <Modules>
            <Module Name="DefaultBlank" />
         </Modules>
      </Configuration>
    </Configurations>
    <Modules>
      <Module Name="DefaultBlank" Url="" Path="">
        <File Url="default.aspx">
        </File>
      </Module>
    </Modules>
</Project>


					  

Configurations

The most important element in the onet.xml file is the Configuration element. Each file can contain more than one Configuration element, and each element must have a unique ID. The Configuration element effectively defines a distinct site definition. Our file has a single site definition named Example19DemoSite, which refers to a module named DefaultBlank.

Modules

Our onet.xml file also contains a Modules section that is outside the Configurations section. These modules can be shared between all configurations in the file. Modules are used to provision files to a SharePoint site and can also be added as feature elements by adding a Module item to a project. In our sample, the default.aspx file is being provisioned to the root of the new site.

Site Features/Web Features

As mentioned, with SharePoint 2010, the recommended approach to creating site definitions is to use features as much as possible. We can specify which features are automatically activated when a site is created by adding Feature nodes to the SiteFeatures and WebFeatures elements. These elements represent features that should be activated at the Site collection level and features that should be activated at the site level.

Add the following XML to the WebFeatures node:

<WebFeatures>
  <!--Example19_Feature2-->
  <Feature ID="69d95a17-8c35-4bbb-9a79-4154fc55be6a" />
  <!--Example19_Feature1-->
  <Feature ID="5fcd733e-2cc9-4363-85fd-dfe7893cb195" />
</WebFeatures>

Features are referenced using their unique identifier. To find the identifier for a particular feature, you can use a few techniques. If the feature is a custom feature, the identifier can be found in the Feature ID property that can be seen in the Properties pane in the Feature Designer. If the feature is an out-of-the-box or third-party feature that’s already installed on a server, the following PowerShell command can provide a list:

get-spfeature|select DisplayName,Id

Our site definition will now automatically activate our two features when a new site is created. Deploy the solution by choosing Build | Deploy in Visual Studio.

After the deployment process has completed, navigate to the sample site that we created earlier, and then select New Site from the Site Actions menu. In the Create dialog, select Example19DemoSite from the SharePoint Customizations category. Name the new site Demo and then click Create. A new site will be created, as shown, that contains the lists defined by our features:

Other -----------------
- SharePoint 2010 : Packaging and Deployment Model - Features (part 3) - Upgrading Features
- SharePoint 2010 : Packaging and Deployment Model - Features (part 2) - Feature Receivers
- SharePoint 2010 : Packaging and Deployment Model - Features (part 1) - Feature Designer
- SharePoint 2010 : Packaging and Deployment Model - Working with Packages
- Microsoft Content Management Server Development : Validating the HtmlPlaceholderControl (part 3) - Building the Required HTML Placeholder Validator
- Microsoft Content Management Server Development : Validating the HtmlPlaceholderControl (part 2) - Checking for an Empty HtmlPlaceholderControl
- Microsoft Content Management Server Development : Validating the HtmlPlaceholderControl (part 1) - Retrieving the Current Value of the HtmlPlaceholderControl
- Windows Server 2003 on HP ProLiant Servers : Migration Case Studies (part 3) - Hewlett-Packard Company
- Windows Server 2003 on HP ProLiant Servers : Migration Case Studies (part 2) - Eastman Chemical Company
- Windows Server 2003 on HP ProLiant Servers : Migration Case Studies (part 1) - County Government Office
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server