Reputation: 751
Within a web part code I have got to transform a sharepoint website in a pdf document, I have completed this. There is an extention that needs to be done, where the PDF document is to only get the published pages.
So I have a list of pages using the "siteMapnodeCollection" and getting the child nodes etc, how do I check that the publishing page represented by a node is actually published & approved?
Thanks
Marc
Upvotes: 1
Views: 3273
Reputation: 52430
See:
Microsoft.SharePoint.Publishing.PublishingPage.IsPublishingPage(listItem)
Microsoft.SharePoint.Publishing.PublishingPage.GetPublishingPage(listItem)
and:
(pageinstance).ListItem.File.Level (should be "Published")
(pageinstance).ListItem.ModerationInformation.Status (should be "Approved")
update:
Most publishing webs are configured to use moderation, but yours may not so you might not have to check for approval.
Upvotes: 3
Reputation: 9117
PublishingPageCollection pages = PublishingWeb.GetPublishingWeb(web).GetPublishingPages();
foreach (PublishingPage page in pages)
{
if(!page.ListItem.File.Level == SPFileLevel.Published)
return;
// logic
}
You can also pass a CAML Query in the GetPublishingPages() method, bringing the items under the correct status.
Upvotes: 1