Tuesday, July 1, 2014

Group custom page layouts in one group

Hi,<br/>


Thanks for reply.<br/>


Actually I have written code to create content type programmatically.


Following code creates CT:



SPContentType parentCT = web.AvailableContentTypes[parentContentType];
contentType = new SPContentType(parentCT, web.ContentTypes, dispalyNameFromResx);
contentType.Group = groupName;
contentType.Description = description;
web.ContentTypes.Add(contentType);
contentType.Update();

I am passing "VDE WebPlus" as contentType.Group, but the page layouts created based on CT do not shown in VDE WebPlus group.

Page layouts get attached with content type on feature activation using this code:



PublishingSite pubSite = new PublishingSite(site);
string vdePageCT = "MyCT";
SPContentType ct = site.RootWeb.ContentTypes[vdePageCT];
if (ct != null)
{
string pageLayoutName = "VdePage.aspx";
string layoutURL = site.ServerRelativeUrl + "_catalogs/masterpage/AuthoringLayouts/" + pageLayoutName;
PageLayout layout = pubSite.PageLayouts[layoutURL];
layout.AssociatedContentType = ct;
layout.Update();
}



Any suggestion?


No comments:

Post a Comment