List Template
List Template

List templates define how to provision particular list types and the content types associated with them, and include the following files:

  • Feature.xml file that identifies the list.

  • Elements file that defines the list template.

  • Schema.xml file that contains the list definition.

List Schema Definitions

A list schema definition constitutes a base definition of a list and defines the fields, views, forms, and toolbar for the list, as well as specifying the content types associated with the list schema.

Content type definitions cascade to all subsites beneath a site; for example, a list at http://Top_Site/sites/Site/Subsite can refer to a content type declared at a higher level parent site in the collection. Lists can either be bound to a single content type, thereby creating a traditional Windows SharePoint Services schema–bound list, or to multiple content types, which creates a heterogeneous list. Regardless of its binding, you should declare the schema in a content type that is stored externally to the list. Because forms are associated with content types, they are declared within content type definitions.

Possible scopes:

  • Farm: No

  • Web Application: No

  • Site Collection: Yes

  • Web Site: Yes

Activation

When a feature that contains a list schema is activated, that list schema is available for creation within the site or site collection.

For more information about the file format of Schema.xml files, see List Definition (Schema.xml) Files.

Community Content

One feature and with multiple list templates does not work
Added by:Thomas Mentzel

My Problem

The creation of one feature with multiple list templates will not work. In my case I created 16 list templates defined in one single feature. The deployment of the solution works perfectly and after the feature activation the list templates are shown in the "Site Actions -> Create" site.

But if you create a list based on one of these list templates (except the first one -see later) you will always get a list based on the first list template of the feature. Take a look at the links of the list templates. You will see that the link contains only the feature id and no reference to the list template within this feature.

As conclusion: one list template per feature.

My Challenge

  1. Create 16 list templates
  2. Create 16 list instances on root site
  3. Create 20 site column definitions. 13 of this site columns use these list instances from point 2 as lookup tables
  4. Some site columns have the same display name than default created site columns e.g. "Status"

My Solution

  1. I created 16 features which contain a list templates each. All 16 features are hidden to ensure a implicit feature activation. A feature is only activated implicitly if they are defined as hidden. After all I created a 17th feature which merges all 16 features by use of activation dependencies. Due to the hidden list template features they are activated automatically. In my "Site Collection Features" list only the "over all" solution is displayed but after activation all 17 features are activated and the list templates are available.
  2. As preface: A site column which is a lookup field points to a lookup list. This list is defined within the site column definition through a guid and not an url. I create the list instance with a feature receiver which implements the "OnActivated" method. Within this method I create the list instances by use of the SharePoint object model. The list creation method returns the guid of the created list ;).
  3. The site column definitions are deployed with xml in the 17th "over all" solution. But I used an empty guid (Guid.Empty.ToString()) for the list reference (!). More details for this "trick" on http://msdn.microsoft.com/en-us/library/ms196289.aspx .
  4. I went around the duplicates with guids because the field definition contains an id attribute which can be used. I encapsulated the id guids with {} to get this work. More on http://msdn.microsoft.com/en-us/library/ms196289.aspx .
© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View