Thursday, January 1, 2009

SharePoint Feature to add site columns

This post explains adding new site column to a SharePoint site. The following simple steps needs to be done to add site columns to a site collection.

1) Identify the Fields (Site Columns), type and its properties. Each Field will have properties like ID(GUID), Display Name, Required, etc.

2) Create a XML file for adding the column information. Ex. “SiteColumns.xml” - This file holds the metadata information related to site columns (Fields). This file information used in
<ElementManifests> section of FEATURE.xml.

3) Create a FEATURE to add these site columns to a site collection.
See the following sample screens to get the better understanding

SiteColumns.xml

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field Type="HTML"
DisplayName="About"
RichText="TRUE"
RichTextMode="FullHtml"
Required="FALSE"
Group="Custom Column"
ID="{246C6CAE-D801-11DD-A840-DC8E55D89593}"
StaticName="About"
Name="About" />


<Field Type="Image"
DisplayName="AboutImage"
RichText="TRUE"
RichTextMode="FullHtml"
Required="FALSE"
Group="Custom Column"
ID="{304952EE-D801-11DD-9B55-0C8F55D89593}"
StaticName="AboutImage"
Name="AboutImage" />
</Elements>


FEATURE.xml


<Feature Id="873CDC1A-D801-11DD-B399-959255D89593"
Title="Add Site Columns Feature"
Description="This Feature adds Site Columns"
Scope="Site"
Hidden="False"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="SiteColumns.xml"/>
</ElementManifests>
</Feature>


This post will also be helpful for the newbie’s to understand about Feature in SharePoint.

No comments: