In a TBB using the TOM.NET API I want to get a list of pages which are published - basically I'm building a sitemap. I am trying to determine if a Tridion.ContentManager.CommunicationManagement.Page is published.
There doesn't seem to be an IsPublished
property or the IsPublishedTo
method.
Is there a Filter condition I can add? E.g.
pageFilter.Conditions["Published"] = "true";
In response to comments:
I'm using the TOM.NET API and I want to get a list of pages which are published - basically I'm building a sitemap.
It seems like the PublicationEngine.IsPublished method is returning "true" if the page is published to the given target anywhere within the BluePrint hierarchy. This doesn't seem like expected behaviour.
In this scenario where you have multiple Publications in the BluePrint, you can use the PublishEngine.GetPublishInfo() method against the page you are on and check if the Publication you are publishing from exists in the Publications returned from that method:
IList<RepositoryLocalObject> rlos = structuregroup.GetItems(pageFilter);
List<Page> pages = new List<Page>(rlos.Count);
foreach (RepositoryLocalObject o in rlos)
{
Page p = (Page) o;
bool isPublished = false;
ICollection<PublishInfo> publishInfo = PublishEngine.GetPublishInfo(p);
foreach (PublishInfo info in publishInfo)
{
if (info.Publication.Id.ItemId == p.Id.PublicationId)
{
isPublished = true;
}
}
if(p != null && isPublished)
{
pages.Add(p);
}
}
You have to be aware that there was a bug in this method where it will always return the current Publication that you are publishing from. This has been fixed in the Hotfix CM_2009.1.74835. You need to apply that otherwise the code above won't work correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With