A SharePoint 2007 list template can be easily developed to reuse it across an organization. In lieu of recreating the list every time you want to use it, a SharePoint list template can be created once, which can then be used whenever creating a new list.

In this blog, we will learn to create a custom solution for SharePoint 2007 that will have custom content types, using which we can create a custom list template.

To start with, we need to install WSPBuilder on our development server that will help us to create custom solution in Visual studio 2005. Once we are done with configuring the WSPBuilder tool on our server, we can start with a custom solution creation.

    1. Open Visual studio and go to File > New > Project that will open a window, where we can see WSPBuilder in Project types. 

    1. Select WSPBuilder project template from the left window, and name the project as SP2007Demo and click OK. As we are using the WSPBuilder project template for our solution, it by default provides a solution structure that can be used for SharePoint site. Here, we do not need to create the whole structure on our own. Below is the solution structure we get:

Now to create a custom list template for SharePoint, we need to follow the steps below:

  • Create custom site columns
  • Create custom site content types
  • Create Custom list template

Create custom site columns

In this section, we are going to create a few custom fields/columns which will be a part of the list template we are planning to create. To add custom fields in SharePoint site, we need to use the SharePoint feature through which we can deploy our custom fields on SharePoint site. So let’s create our first SP2007 feature.

    1. Right click on Project and select Add > New Item. A dialog box will open as below:

    1. Select Blank Feature and name it ConfigurationFeature, and click on Add button. It will open another dialog to setup feature settings.

    1. Set Scope value as Site. This will add our first feature in SharePoint solution:

    1. Edit the element.xml file with following values:

We have created an XML structure for our custom fields, which are going to be deployed on SharePoint 2007 site through ConfigurationFeature feature we added.

Note: To generate ID you can use the Create GUID feature available under Tools in Visual Studio.

Now let us deploy this feature on our site and see do we get these columns in our site or note.

    1. To deploy the solution on SharePoint, right click on Project and under WSPBuilder, click on Deploy.

Once the deployment gets done, go to the site and check site collection feature where you will be able to see a custom feature in list.

  1. Click on Activate button and go to Site Settings > Site Columnspage, which will show all the site columns available in your site. Select Custom Columnsgroup from dropdown available on right side on page to filter the list. There we can see the fields we have added through our custom feature.

    Create custom site content types

    Once we are done with creating our own custom fields for SharePoint site, the next step is to create a site content type.

    So what exactly a site content type is and what’s the use of it? The answer is, Content Type gets used for virtual grouping of SharePoint columns or fields and use it as a reusable component. Content type contents reference of all the fields which you want it to be part of that Content Type.

    Now let’s create a custom content type with reference of the above fields we have created.

    Add one more feature like we did in Create custom site columns section as name EmpContentTypeFeature and the scope of that feature will be Site level. Once the feature gets added update the elements.xml file as below screenshot.

In the above screenshot, as we see, we have referenced the custom fields we have created by using their ID and Name properties.

Once you deploy the solution on your site and activate EmpContentTypeFeature feature, you will be able to see the EmpContentType content type by going at Site Settings > Site Content Type page.

This content type can be used for any list, library or pages.

Create custom list template

After creating custom content type which is referencing our custom fields only, we will leverage that content type and create a list template out of it.

To create custom list template first we need to do is add a new feature in our solution with name EmpListTemplate and update the element.xml file of that feature as below:

Here we have used this XML file to create a custom list template with name as EmpListTemplate with some predefined properties like i.e. Name, Type, BaseType, etc.

Now, for creating this custom template we provide schema, to do so we need to add a folder in this feature with name EmpListTemplate that is same as the Name property in element.xml file.

In that folder, add an XML file with the name schema.xml. Now once you add that, your solution will look like this:

To update the schema.xml file, we have to use a predefined format that will contain the definition for list templates i.e. View, Content Type, fields, etc. We can get the format from the following location:

C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATEFEATURESCustomListCustListschema.xml.

Copy the file content in our solution schema.xml file and update the file as below:

Once we deploy the solution on our site, we can see a custom template once we go to View All Site Content > Create.

Posted by Advaiya

    Let's connect to make technology work for you.

    Please tick the options most relevant to your business challenges
    Decision makingBusiness productivityCustomer experienceTechnology-led innovationDigital transformation

    [By using this form you agree with the storage and handling of your data by this website.]