Pages

Monday, April 4, 2011

All About List/Site Definition– Part II: Create Site Definition and Staple list definition/instance Features

In the first part of this series of posts I had described on how to develop list definition and list instance. In this post I’ll explain how to use those list definition and list instance with site definition so that the list item is created on new site creation. Just to recall, in the first post, I had got two features that I need to active on site creation.

Now you have your list definition and list instance ready (with two features). Now you need to create a site definition. To create a site definition to an existing SharePoint Project you need to install Community Kit for SharePoint: Development Tools edition visual studio extension.

Step1: Add the site definition in the Project: Click Add new item and from the Add new item dialog click “Blank Site Definition (CKSDev)” as shown below:

image_thumb51e

Figure 1: Add Blank Site definition item (Need to install CKSDev VS extension)

Once you have added the Blank Site Definition, you will find three files are added in the project.

Step 2: Modify webtemp file: You can find a file named like webtemp_sitedefinition in the site template folder. This file defines the template names, title, groups etc. Open the file and modify the description and displaycategories. However, don’t change the template name in the editor as the template name in this file related to template folder in the solution explorer as shown below:

image

Figure 2: Template file editing

Step 3: Modify Onet.xml file: One of the file is Onet.xml which is the key player in customization. If you can remember from part I of this series of post, that we had two features: one was for list definition scoped at site level and another was for list instance scoped at web level. Open the Onet.xml file and add the list definition and list instance feature IDs in SiteFeatures and WebFeatures section correspondingly as shown below:

image_thumb91

Figure 3: Features to be activated defined in Site Definition

And you are done! Now build the solution and deploy. Once deployment done, try to create a site with the new site template, if everything works out then in the new site you will find your list created.

 

In the next part I’ll explain more about Provisioning the site. The next part is here.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.