8

I want to check if a page is published or not.

TDSItems listPage = SGroup.GetItems(ItemType.ItemTypePage);

foreach (Page newPage in listPage)
{
    tcm = newPage.Info.ID;
}

I can see info properties but i don't know where I can get the publish status.

Thanks!

4 Answers 4

8

By using method IsPublished of class PublishEngine with parameters Page and PublicationTarget, you can find the publish status

public void Transform(Engine engine, Package package) {
    Item pageItem = package.GetByType(ContentType.Page);
    Page page = engine.GetObject(pageItem.GetAsSource().GetValue("ID")) as Page;
    PublicationTarget pubTarget = new PublicationTarget(new TcmUri("tcm:0-123-65537"), engine.GetSession());
    bool isPublished = PublishEngine.IsPublished(page, pubTarget);
}
1
  • Is it possible for you to add a little more background information? I would like to know how to do this, but I'm not fully understanding what I see here. Perhaps you have a web page reference you could provide. THANKS!
    – MADCookie
    Commented Mar 21, 2013 at 21:37
5

I can't use the method IsPublished, so I finally used IsPublishedTo(object pubTarget) which returns true if the page is published in a given publication target and it works.

foreach (PublicationTarget target in tdse.GetPublicationTargets())
{
    TDSItems listPage = SGroup.GetItems(ItemType.ItemTypePage);

    foreach (Page newPage in listPage)
    {
        if (newPage.IsPublishedTo(target) != false)
    }
}
3

It looks like you're using TOM, not TOM.NET. In this case use page.IsPublished() which returns true if the page is published to the given pub target.

1

If want to be totally sure, you could use invoke a curl or make a http request from c# to check that the page is also deployed as 'page.IsPublished()' will only check if the page is flagged as published in the DB

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.