3

Do you know if there is any way to get list of all published pages for specific publication by using Content Delivery API?

Something similar to next API, but for pages:

new PublicationMetaFactory().getAllMeta();

2 Answers 2

5

Here is the working code example for getting the published pages items:

    int publicationId = 8; //change this value to your publicationId on your environment   
    PublicationCriteria publicationCiteria = new PublicationCriteria(publicationId);
    ItemTypeCriteria itemCriteria = new ItemTypeCriteria(64);
    Query query = new Query(CriteriaFactory.And(new Criteria[] { publicationCiteria, itemCriteria }));
    SortParameter sortParameter = new SortParameter(SortParameter.ItemLastPublishedDate, SortParameter.Descending);
    query.AddSorting(sortParameter);
    string[] itemIds = query.ExecuteQuery();

I hope it helps.

1
  • Right, we need to use Query object. Thanks! Commented Jan 30, 2018 at 20:24
4

Haven't tested this, but I would probably use a Query object with its Criteria property set accordingly.

Meaning:

  • PublicationCriteria to select the desired publication
  • ItemTypeCriteria to select only pages.

Make sure to "And" these two criteria together. Once you have the criteria, you would simply call ExecuteQuery on the Query object and it will return the list of Tcm-s. Since this is the CD we're talking about, you will only get the Items present there, in other words, only the published ones.

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.