My new blog

My blog has moved to www.davehunter.co.uk/blog see you there.
Showing posts with label Content Types Viewer. Show all posts
Showing posts with label Content Types Viewer. Show all posts

Thursday, 21 June 2007

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.

Tuesday, 19 June 2007

Using the Content Types Viewer

The content types viewer is a windows form which displays information about content types that exist in SharePoint 2007. I came to write the tool because creating custom content types using features was quite time consuming. Creating content types with a web browser is more intuitive but there is no easy way to deploy them. The content types viewer looks like:




Download it here http://www.codeplex.com/MOSS2K7CTypesViewer/

How to use the content types viewer

  1. Type in the url of the site collection where the content types are. Then click on "GO".
  2. Select a content type from the list of content types displayed.
  3. You have 3 choices. You can view the schema of the content type by clicking "Show Schema". You can also view the fields (the xml displayed is used for features that create site columns) by clicking "Show Fields" and field refs (the xml displayed is used for features that create content types) by clicking "Show Field Refs".

Show Schema example:


Show Fields example:



Show Field Refs example:



Comming soon ... creating content types with the Content Types Viewer.

Updated: Creating content types with the Content Types Viewer