Wss3sdk: how to add content types to the list

Source: Internet
Author: User

You can reference the content type in a list definition so that the type list is created by the user. WSS will include the content type in the list by default.

The list definition can be included in the feature.

After creating a list, you can use the WSS object model to add content types.

Specify the content type in the list definition

If you want to define
To add a content type, you can add a contenttypes element in the list architecture. The contenttypes element contains a contenttyperef
Element Set. Each contenttyperef element specifies the website content type in WSS. When a user creates a list of this type, it is copied to the local list and becomes the list content class.
Type. The contenttyperef element only contains one attribute,IDTo specify the content type ID.

The content type of the website you reference must be in the same scope as that of the list. That is to say, it is also at the higher level of the website set or website.

The list element contains an attribute,AllowmultiplecontenttypesThis attribute must be set to true to allow the list to contain multiple content types during creation. At the same time, the list element also includes an attribute,EnablecontenttypesTo allow WSS to display multiple content types in the list.

Note::
When the WSS creates a list, only the columns defined in the basic architecture or list architecture of the list are created. If the columns of the website content type you reference in the list architecture are not included in the List infrastructure or list architecture, these columns will not be created in the list. You must also include these columns in the List Schema to add them when creating the list.

Add a content type to the list definition

1. In the list definition XML,ContenttypesAddContenttypeElement.
2. SettingsContenttypeElementIDThe ID of the content type that the property category wants to include in the list.

Add content types for existing lists

You can use the WSS object model to add content types to a created list.

Procedure:

1. PassAvailablecontenttypesMethod to return all available content types in the website where the list is located. This method returnsSpcontenttypecollectionObject.

2. DefineSpcontenttypeObject To make it equal to a variable in the set that you want to add to the listSpcontenttypeObject.

3. PassContenttypesAttribute to access a set of list content types based on a specific list. This method returnsSpcontenttypecollectionObject.

4. CallAddMethod to addSpcontenttypeObject To the list content type set.

The content type of the website you want to add must be within the accessible range of the list, that is, it must be defined in the same website or its higher level.
After you add a website content type to the list using the object model, WSS automatically adds all columns of this content type to the list (if this column is not available before ). This is achieved by comparing existing list instances and content types. In this case, if you want to add other list columns to the list content type, it must be performed explicitly.

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.