Export (0) Print
Expand All
53 out of 55 rated this helpful - Rate this topic

How to: Add a Content Type to a Site

Windows SharePoint Services 3

You can specify content types to include in a site definition, so that each time a user provisions a site of that type, Windows SharePoint Services makes those site content types available on the site by default.

Site definitions can be included in Features. For more information, see Working with Features.

After a user provisions a site, you can add content types to that site through the Windows SharePoint Services object model.

Specifying Content Types in a Site Definition

To specify a content type to include in a site definition, you first create the content type as a separate Feature, and then reference that Feature in the site definition.

To specify a content type to included in a site definition

  1. Create the content type as a separate Feature.

    For more information, see Working with Features.

  2. Reference that Feature in the feature that defines your site:

    1. In your site Feature, open the XML file that defines your site.

    2. In the Project element, under the Categories and Category elements, add a reference to the content type Feature in either the SiteFeatures or WebFeatures element. For example:

      <SiteFeatures>

      <Feature ID="00BFEA71-1C5E-4A24-B310-BA51C3EB7A57" />

      <Feature ID="695B6570-ACDC-4A8E-8545-26EA7FC1D162" />

      </SiteFeatures>

      <WebFeatures>

      <Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5" />

      <Feature ID="00BFEA71-E717-4E80-DEAF-D0C71B360101" />

      </WebFeatures>

Adding Content Types to a Provisioned Site

You can add content types to a provisioned site through the Windows SharePoint Services object model.

To add a content type to a provisioned site

  1. Use the AvailableContentTypes method to access the content types that are available for the site. This method returns an SPContentTypeCollection object.

  2. Create a SPContentType object using the SPContentType method.

  3. Use the Add method to add the SPContentType object to the site content type collection.

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.