People from all areas of SharePoint always reference the uses of 'Content Types'. The best definition I can give to help people understand SharePoint Content Types is that they are SharePoint business objects in a nutshell. SharePoint uses content types for everything. They are the main building blocks for your informtion for your information architecture. Here is some example code to show you all the content types available in your sharepoint site:
using (SPSite site = new SPSite("http://localhost:30005"))
{
foreach (SPContentType ct in site.RootWeb.ContentTypes)
{
//Prints out each content type in your site
Console.WriteLine(ct.Name + " (" + ct.ParentName + ")" + ct.Id);
foreach (SPField field in ct.Fields)
{
//Prints out each column that is in that content type
Console.WriteLine("\t" + field.StaticName);
}
Console.ReadLine();
}
}
Hope this helps!
No comments:
Post a Comment