var ctypename = @"MyCustom Content Type";
var ctypedescription = @"Create a new Custom Content Tye.";
var ctypegroup = @"Custom Content Types";
var sitecolumnname = @"Headline";
var sitecolumngroup = @"Project Site Columns";
var web = (SPWeb)properties.Feature.Parent;
// create content type
var contentType = new SPContentType(web.ContentTypes["Document"], web.ContentTypes, ctypename);
contentType.Description = ctypedescription;
contentType.Group = ctypegroup;
contentType = web.ContentTypes.Add(contentType);
// add site column
web.Fields.Add(sitecolumnname, SPFieldType.Note, false);
var headlineSiteColumn = web.Fields[sitecolumnname];
headlineSiteColumn.Type =SPFieldType.Note;
headlineSiteColumn.Group = sitecolumngroup;
headlineSiteColumn.Update();
// add site column to content type
contentType.FieldLinks.Add(new SPFieldLink(headlineSiteColumn));
contentType.Update();
var ctypedescription = @"Create a new Custom Content Tye.";
var ctypegroup = @"Custom Content Types";
var sitecolumnname = @"Headline";
var sitecolumngroup = @"Project Site Columns";
var web = (SPWeb)properties.Feature.Parent;
// create content type
var contentType = new SPContentType(web.ContentTypes["Document"], web.ContentTypes, ctypename);
contentType.Description = ctypedescription;
contentType.Group = ctypegroup;
contentType = web.ContentTypes.Add(contentType);
// add site column
web.Fields.Add(sitecolumnname, SPFieldType.Note, false);
var headlineSiteColumn = web.Fields[sitecolumnname];
headlineSiteColumn.Type =SPFieldType.Note;
headlineSiteColumn.Group = sitecolumngroup;
headlineSiteColumn.Update();
// add site column to content type
contentType.FieldLinks.Add(new SPFieldLink(headlineSiteColumn));
contentType.Update();
No comments:
Post a Comment