I have deployed a custom site definition.. Features available in onet.xml are -
Site Features-
SharePoint Server Publishing Infrastructure
Publishing Workflow feature
Web Features
Office SharePoint Server Publishing.
I also have 3 modules, that deploys master pages, page layouts and display templates respectively.
Now I have added a feature receiver and on feature activating , I am creating Publishing Pages based on the deployed custom page layout. Code is below.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
System.IO.File.AppendAllText(@"C:\Users\ADLATempSPAdmin\Desktop\Logging.txt", "started");
SPSite site1 = properties.Feature.Parent as SPSite;
SPWeb web1 = site1.OpenWeb();
PublishingSite PublishingSite = new PublishingSite(site1);
PublishingWeb publishingWeb1 = PublishingWeb.GetPublishingWeb(web1);
string pageName1 = "MyCustomPage.aspx";
SPContentType ctype = PublishingSite.ContentTypes["Article Page"];
PageLayoutCollection pageLayouts = PublishingSite.GetPageLayouts(ctype, true);
System.IO.File.AppendAllText(@"C:\Users\ADLATempSPAdmin\Desktop\Logging.txt", web1.Url);
PageLayout pageLayout = pageLayouts[web1.Url + "/_catalogs/masterpage/SchoolLayout.aspx"];
//PageLayout[] pageLayouts1 = publishingWeb1.GetAvailablePageLayouts();
//PageLayout currPageLayout = pageLayouts1[0];
PublishingPageCollection pages = publishingWeb1.GetPublishingPages();
PublishingPage newPage1 = pages.Add(pageName1, pageLayout);
newPage1.ListItem[FieldId.PublishingPageContent] = "This is my content";
newPage1.ListItem.Update();
newPage1.Update();
newPage1.CheckIn("This is just a comment");
}
But I am getting error while creating a site collection, based on my custom site definition. "
The site is not valid. The ‘Pages’ document library is missing.
I read that, our feature receivers should not have dependencies on the features written in onet.xml. Is that right?
If so, my publishing feature is activated after my event is fired. so "Pages" document library is not present.
How should I proceed now. I am scratching my head for days in this. Please help.