Friday, November 12, 2010

SharePoint 2010 Web Content Management (WCM) Metadata – Site Columns & Content Types





For creating a page layout we need to create a custom content type. And for creating a content type, we need to create custom site columns. Below I will demonstrate how to create custom site columns declaratively.

1. Branding – Master Page & Custom Style Sheet 
2. Metadata – Site Columns & Content Types
3. Page Layouts
4. Setting up deployment Paths & Jobs




Step 1. Add empty element to the project. In the elements.xml file you can declare the columns like below. Declarative site columns can also be defined in content type’s Elements.xml file. But for clarity, I have created a new element and declared the site columns in here…
 
Different types of site columns – Text, Choice, Number & Note.
And finally for displaying image…


I have created site columns of different types, Text, Choice, Number, Note and URL. For Choice (drop down list) column we can add choices in the tag provided. For displaying image, we can choose a URL column and set the format property to “Image”. This will allow the user to enter the URL of the image.

Step 2. Add Content type element to the project. This content type is based on article page. The ID property is generated by default. We have to set Name, Group, Description, Inherits & Version values.

 
Content Type Elements.xml file with custom site columns added
 
Step 3. Now in the field refs tag add all the custom site columns already created.

Step 4. Deploy the solution. Now go to site settings and check if all the site columns and content types are available. Also check if all the site columns are available in the custom content type.

The next step is to associate this content type to the page layout and place the site columns on the page layout.


- Vighnesh Bendre 

No comments: