Sunday, March 7, 2010

Content Types

Creating Content Types with the Content Types Viewer
This post shows how to create content types using the Content Types Viewer and features. In this post we are going to create a "car" content type with a "door", "engine" and "colour" site columns. This post assumes you are familiar with SharePoint 2007 administration.

The Content Types Viewer is available to download from http://www.codeplex.com/MOSS2K7CTypesViewer/


1. Once on your SharePoint 2007 site go to site settings and the site column gallery.

2. Create a new "doors" site column as a number attribute.


Tip: Always create new site columns or content types in a custom folder. This makes them easy to find and separates them from the out of the box ones.
 
3. Create a new "engine" site column as a string attribute.
 
4. Create a new "colour" site column as a choice attribute (add any colours for the choices).



5. Create a new "Car" content type inheriting from a list item.
 
6. Add the newly created site columns to the "Car" content type.
 
7. Run the Content Types View. Type in the URL of the site collection and click "GO".
 

8. Select the "Car" content type. 

9. Click on the "Show Fields" button.
10. Create a new folder called "DemoSiteColumns" under C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\.
 11. Create a new file called features.xml containing:
<Feature Id="F5E3FEE8-1D9B-4b95-848B-7614D638B90D" Title="Demo Site Columns" xmlns="http://schemas.microsoft.com/sharepoint/" Description="Enables the Demo Site Columns" version="1.0.0.0" scope="Site" hidden="FALSE">
<ElementManifests>
<ElementManifest Location="elements.xml">
ElementManifests>
Feature>

12. Create a new file called elements.xml.

13. Open elements.xml in notepad. Click on the "Copy to Clipboard" button from the Content Types Viewer.

14. Select edit > paste from the notepad window and save changes to the elements.xml file.

15. Click on the "Show Field Refs" button.
 
16. Create a new folder called "DemoContentType" under C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\

17. Create a new file called features.xml containing:
<Feature Id="3B4752E6-8D62-4df0-A4D3-31C8E99D44FC" Title="Demo Content Type" xmlns="http://schemas.microsoft.com/sharepoint/" Description="Enables the Demo Content Type" version="1.0.0.0" scope="Site" hidden="FALSE">
<ElementManifests>
<ElementManifest Location="elements.xml">
ElementManifests>
Feature>

18. Create a new file called elements.xml.

19. Open elements.xml in notepad. Click on the "Copy to Clipboard" button from the Content Types Viewer.

20. Select edit > paste from the notepad window and save changes to the elements.xml file.

21. Open a command prompt and type the following:

CD C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin
stsadm -o installfeature -file DemoSiteColumnsstsadm -o installfeature -file DemoContentType

22. Before activating the features either delete the existing site columns and content types or activate the features in a different site collection.

23. Go back to the command prompt and type the following:

stsadm -o activatefeature -file DemoSiteColumns -url http://localhost/
stsadm -o activatefeature -file DemoContentType -url http://localhost/

You have now created two features which create the site columns and the "Car" content type.


5 comments:

  1. Great article! We աill be linking tο thіs ρarticularly ցreat
    post ߋn our website. Keeƿ up tthe greаt writing.


    mу homepage: condominium for rent

    ReplyDelete
  2. Hmm is anyone else encountering problems with the pictures on this blog loading?

    I'm trying to determine if its a problem on my end or if it's the blog.
    Any feed-back would be greatly appreciated.

    Check out my web blog - results of lok sabha elections

    ReplyDelete
  3. Hmm is anyone else having problems with the images on this
    blog loading? I'm trying to figure out if its a problem on my end
    or if it's the blog. Any feedback would be greatly appreciated.



    Here is my blog :: wedding anniversary gifts (wiki.zep.it)

    ReplyDelete
  4. I've been exploring for a little bit for any high quality articles or blog posts on this
    kind of space . Exploring in Yahoo I finally stumbled upon this web site.
    Studying this information So i'm happy to convey that I have a
    very excellent uncanny feeling I came upon just what I needed.
    I so much surely will make certain to do not put
    out of your mind this web site and provides it a glance regularly.


    Stop by my page custom wedding cake topper ()

    ReplyDelete