Marc G
Marc G

Reputation: 751

How to determine if a Publishing Page in Sharepoint 2007 is actually published

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

Answers (2)

x0n
x0n

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

Francisco Aquino
Francisco Aquino

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

Related Questions