Tridion 2009 TBB: How to determine if a page is published for a specific publication?

In TBB using the TOM.NET API, I want to get a list of published pages - basically I create a sitemap. I am trying to determine if the Tridion.ContentManager.CommunicationManagement.Page file has been published.

There does not seem to be an IsPublished or IsPublishedTo .

Is there a filter condition that I can add? For instance.

 pageFilter.Conditions["Published"] = "true"; 

In response to the comments:

I use the TOM.NET API and I want to get a list of published pages - basically I create a sitemap.

It seems that the PublicationEngine.IsPublished method returns โ€œtrueโ€ if the page is published for this purpose anywhere in the BluePrint hierarchy. This is not like expected behavior.

+4
source share
4 answers

In this case, when you have several publications in BluePrint, you can use the PublishEngine.GetPublishInfo () method on the page you are on and check if there is a publication that you published in publications obtained from this 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 should know that there was an error in this method in which it will always return the current publication from which you are publishing. This is fixed in patch CM_2009.1.74835. You need to apply this, otherwise the code above will not work correctly.

+4
source

You should use OrganizationalItemItemsFilter :

 var filter = new OrganizationalItemItemsFilter(session); filter.BaseColumns = ListBaseColumns.Extended; var structureGroup = (StructureGroup)session.GetObject("tcm:2-5-4"); var result = structureGroup.GetListItems(filter); 

It will return you a list as follows:

 <tcm:ListItems Managed="68" ID="tcm:2-5-4" xmlns:tcm="http://www.tridion.com/ContentManager/5.0"> <tcm:Item ID="tcm:2-46-64" Title="p" Type="64" Modified="2012-03-19T16:21:10" IsNew="false" Icon="T64L0P0" IsPublished="false" Lock="0" IsShared="false" IsLocalized="false" Trustee="tcm:0-0-0" /> </tcm:ListItems> 

You can check the properties of OrganizationalItemItemsFilter for IncludePathColumn options like Recursive or IncludePathColumn

But be careful with this approach, as it will only tell you if it is published anywhere, but not necessarily for the targeted publication that you expect.

+4
source

After searching by filter, you can try using the PublishEngine.IsPublished method:

 public static bool IsPublished( IdentifiableObject item, PublicationTarget publicationTarget ) 

Returns whether this item is published in the specified PublicationTarget publication.

+3
source

I do not understand your expression, published in a separate publication. The page is inside the publication and can be published in one or more target values โ€‹โ€‹for the publication (and this can be done for each publication on which the page is located, if it is printed in blue).

So, to find out if a particular page is published, you need to check if it is published for at least one purpose. This can be done directly in the list using OrganizationalItemItemsFilter. The returned list will show you for each item, regardless of whether it is published or not:

 <tcm:Item ID="tcm:2-46-64" Title="p" Type="64" Modified="2012-03-19T16:21:10" IsNew="false" Icon="T64L0P0" IsPublished="false" Lock="0" IsShared="false" IsLocalized="false" Trustee="tcm:0-0-0" /> 

Here you see that the tcm: 2-46-64 Page is not being published. if we examine the unique identifier of this page, we see that it is in the publication tcm: 0-2-1 (the publication identifier is the first number in the TCM element URI).

Now, if the IsPublished attribute is set to "true", this will mean that this page (in its publication) is published for at least one purpose.

To find out what purpose this page is published for, you can use the PublishEngine.IsPublished method. An identifiable object that must be specified as the first parameter will have the identifier of your page. It doesnโ€™t matter if we are talking about a generic (BluePrinted), localized or local element. The publication identifier in the TCM URI of your page will tell you from which publication the publication of the page is in this case.

Note that you need to use the 3rd overload: IsPublished (IdentifiableObject item, PublicationTarget publishTarget, bool isPublishedInContext) and set the last parameter to true. This will give you publication status only for the specified item, and not for any of its (BluePrint) parents or children.

+3
source

Source: https://habr.com/ru/post/1402241/


All Articles