To created and deployed custom Content type using both sharepoint object model and feature below are the details.
For Custom content type using feature. We have feature.xml which points to element.xml. Element.xml has contenttype id which is inherited from one of the parent content type. We also have name,group,inherit, version under contenttype tag. If we have to add new field to the contenttype we have Field tag added to element.xml file with GUID, field type, name etc. Than we add FieldRef tag which points to the field required. Deploy your feature and enable content type in advance settings and apply contenttype to the list.
Contenttype id can be used as:- 0x0101 for document library from which it inherits, append 00 and then append GUID without punctuations. To crate child contenttype of this custom contenttype its append 01/02/03
Using SharePoint object model - Use site.fields.add(); to add site column. Use SPContentType and pass ParentContentType object in constuctor. Use Site.ContentType.add(). To add site columns to contenttype, use ContentType.FieldLink.add();
Example:- In an orginization, there are multiple team sites where the team manager uplaods project plan in the doucment library. Now we need 2 more fields of matadata added to project plan document library in every team site. This is where Content Types come into picture. So i will assocaite 2 site columns with content type and associate with all the project plan document library in site collection.
ContentTypeUsage class help to identify if the required contenttype is in use before deleting it. We can also use powershell script.
ContentType has to inherit from a parent contenttype. Its a parent child relationship. Inheritance model is little different here. If you make any changes in the parent contenttype then the changes will not be reflected in the child contenttype automatically. Developer has to push down manually or through code. Similarly for the list and libraries that inhert from content type internally makes a seperate copy of contenttype list and developer has to push down overriding any changes made in child contenttype.
We can also associate document template type to contenttype by both feature and SharePoint object model. Using documentTemplate tag and mention TargetName to document template name which resides under catalogs. Using Site.file.add() and SPContentType.DocumentTemplate = "DocumnetTemplate Name".
Associate Contenttype to list definition. Make changes in schema.xml and in ContentType tag we have ContentTypeRef tag which asks for ID
On Production we can update existing contenttype by 2 ways. Create a new contenttype with updated columns and in feature reciever code hide the old contenttype. Here element.xml gets execuated 1st and then the active feature method. The second way is update existing contenttype using sharepoint object model. Here we have to do push down by spcontenttype.update(true);
If we have multiple(3) content types associated with a list, then we need to have 3 different list views. For doing the same we have "Metadata Navigation" in list settings which gives herichicy of contenttype in left navigation to choice from. "Per-location view setting" is another option in list setting which help to map specific view with its corresponding create list view.
Content Type Hub is new is SharePoint 2010 where we can share a content type within multiple web application. For this we have to create content type in on of the site collection. Then create Managed Metadata Service Application and define this content type in its properties.