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:
You have now created two features which create the site columns and the "Car" content type.