Wss3sdk: create a custom list definition through feature

Source: Internet
Author: User

This task shows how to create a custom list template feature and add itCreateAvailable List Templates on the page. To add a custom list definition, you must provide the following three files:

    • Feature. XML is used to register a list template.

    • Elements. XML adds the list templateCreatePage.

    • Schema. xml defines the structure of the list, which content types are associated, the definition of fields and views, and the reference of forms and toolbar.

Procedure
  1. InLocal_drive: \ Program Files \ common files \ microsoft shared \ Web Server Extensions \ 12 \ Templates \ featuresCreate a folder and give it a proper name, such as simplelistfeature.

  2. Create an ifeature. xml file in the new folder, specify the title, ID, and scope of feature, and the location of the elements. xml file, as shown below:

    < Feature Title = "Simple list feature" ID = "Guid" Scope = "Web" Xmlns = "Http://schemas.microsoft.com/sharepoint" >
    < Elementmanifests >
    < Elementmanifest Location = "Elements. xml"   />
    </ Elementmanifests >
    </ Feature >
  3. Replace the aboveGuidPlaceholder. Run guidgen.exe to obtain a new guid.Local_drive: \ Program Files \ Microsoft Visual Studio 8 \ common7 \ tools.

  4. Create an elements. xml file in the new folder to identify the list template and specifyCreatePage Information. Specify a type value greater than 10000, and do not use the same value as other custom list values.

    < Elements >
    < Listtemplate Name = "Simplelist" Displayname = "Simple list" Type = "10001"
    Description = "This is my simple list ." Basetype = "0" Onquicklaunch = "False" Securitybits = "11"   />
    </ Elements >

  5. Create a subfolder with the same name as the one previously assigned to the list template, for example, simplelist.

  6. Create a schema. xml file in the subfolder to define the list.

  7. In the command line, enter the following command to install and activate the feature on a specific subnet.
    A. stsadm-O installfeature-filename simplelistfeature \ feature. xml
    B. stsadm-O activatefeature-name simplelistfeature-URL http: // server/site/subsite

  8. NavigateCreatePage to see the effect, you can create a list by applying this template.

Schema. xml file

At the beginning of Schema. XML, any custom fields required for the list are defined. In the following example, an option type field is defined for the list:

< List Name = "Simplelist" Title = "Simple list" Basetype = "0" Direction = "" URL = "" >
< Metadata >
< Fields >
< Field Type = "Choice" Name = "Favoritecolor" Displayname = "Favorite color" >
< Choices >
< Choice > Red </ Choice >
< Choice > Green </ Choice >
< Choice > Blue </ Choice >
</ Choices >
</ Field >
</ Fields >
< Views >
< View Baseviewid = "1" Type = "Html" Webpartzoneid = "Main"
Displayname = "$ Resources: Core, objectiv_schema_mwsidcam1_c24 ;"
Defaultview = "True" Setuppath = "Pages \ viewpage. aspx"
Imageurl = "/_ Layouts/images/generic.png" URL = "Allitems. aspx" >

Add a reference for this fieldViewfieldsTo display this field in the List View and list item form.

< Viewfields >
< Fieldref Name = "Docicon" />
< Fieldref Name = "Attachments" />
< Fieldref Name = "Linktitle" />
< Fieldref Name = "Favoritecolor" />
</ Viewfields >

You can copy a schema. xml file defined in the existing list and modify it accordingly. In this way, you can quickly create a custom list.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.