MOSS9 / Creating Publishing Content Types

SharePoint team and Project server team at Maven Infosoft has great experience of creating web application based on MOSS 2007 and Project server 2007. That includes customization and development of webpart, site definitions, theme development, extension development, module creation. The team has developed CRM application, Job portal, Project management, to CMS applications based on MOSS 2007 and project server 2007.

Team would like to share same experience. This can help who wanted to begin with the sharePoint development and Project Server development.

There are list of articles start with SP and from number 1 to …. Always start with the article SP1 and read next article to start working on MOSS easily and quickly.

How to Create Site Columns:

Before going into detail on the creation of content types via features it is important to understand how Content type IDs work.

You should read the following MSDN page that explains about ContenTypes IDs and their inheritance based model: http://msdn2.microsoft.com/en-us/library/aa543822.aspx

Since this post shows how to create Publishing Content Types we need to find from which existing content type we want to base our own. I did some research on the features that are installed and activated when you use the Publishing site. In there we can see that the base content type from which we want to inherit is the “Page”. This Content Type has an ID of:

0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB0
64584E219954237AF39

So in order to create our own ID we can add two hexadecimal values, or, we can add “00” followed by a GUID. I prefer this approach as it is unique and identifies custom content types more easily.

So my content type ID can be:

0x010100C568DB52D9D0A14D9B2FDCC96666E9F20079481
30EC3DB064584E219954237AF3900ADB88465BE2C439798977662094183BC

The bold text is the Page content type ID to which I append “00” and a new GUID.

Content Type Schema:

Second important piece of information is the Content Type schema. I could not find any information specific to publishing content types on MSDN or the MOSS SDK. So again the solution is to use the available information together with some nosing in the publishing features installed by MOSS in the 12 hive. ContentType schema on MSDN: http://msdn2.microsoft.com/en-us/library/aa544268.aspx

In the following sample I’m creating two content types: a product content type and a hardware product content type. You will see that the hardware product content type inherits from the product content type by appending 00 + a new GUID to the ID.

<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”>

<!– Product base content type –>
<ContentType ID=”0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007
948130EC3DB064584E219954237AF3900ADB88465BE2C43979
8977662094183BC” Name=”$Resources:contenttype_productbase_name;” Description=”$Resources:contenttype_productbase_description;” Group=”$Resources:group_productcontenttypes;” Sealed=”FALSE” Version=”0″>
<FieldRefs>
<FieldRef ID=”{F44BFBB0-4725-4167-B976-F85F84131AA3}” Name=”ProductCategory” Required=”FALSE” />
<FieldRef ID=”{EB19D87C-5DEE-4a73-85E0-506293D422D9}” Name=”ProductName” Required=”TRUE” />
<FieldRef ID=”{D73843E5-0D9F-4400-BC75-1A4C2BD27900}” Name=”ProductIntro” Required=”TRUE” />
<FieldRef ID=”{894635F9-1DF8-46f1-BC47-46EFF09FEF3D}” Name=”ProductDescription” Required=”FALSE” />
<FieldRef ID=”{D89C9409-2A97-4a7a-81F5-7D45E7CD8D6B}” Name=”LaunchDate” Required=”TRUE” />
<FieldRef ID=”{6036ECDE-521A-4dbe-94B4-40E0E4EF7029}” Name=”ProductImage” Required=”FALSE” />
<FieldRef ID=”{F31DF817-D220-4449-BD6F-2F1B7C0823ED}” Name=”ProductPrice” Required=”TRUE” />
</FieldRefs>
<DocumentTemplate TargetName=”/_layouts/CreatePage.aspx” />
</ContentType>

<ContentType ID=”0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3D
B064584E219954237AF3900ADB88465BE2C439798977662094183BC00B2DE
F3B02D274199BFF43C6D2F129D99″ Name=”$Resources:contenttype_hardwareproduct_name;” Group=”$Resources:group_productcontenttypes;” Sealed=”FALSE” Version=”0″>
<FieldRefs>
<FieldRef ID=”{6A08E31A-0620-45df-BAC1-54A4D0FBFDCE}” Name=”ProductManual” />
</FieldRefs>
<DocumentTemplate TargetName=”/_layouts/CreatePage.aspx” />
</ContentType>

</Elements>

Now we need to add this to the feature and install it together with what was done in part I of this series.

The complete feature can be downloaded from the official website.