tags:

views:

169

answers:

2

Hi,

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

+2  A: 

See:

  • Microsoft.SharePoint.Publishing.PublishingPage.IsPublishingPage(listItem)
  • Microsoft.SharePoint.Publishing.PublishingPage.GetPublishingPage(listItem)

and:

  • (pageinstance).ListItem.File.Level (should be "Published")
  • (pageinstance).ListItem.File.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.

-Oisin

x0n
+1  A: 

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.

F.Aquino