Get parent info of specific page type

Sylvain C. asked on April 12, 2022 16:21

Hi, I have the following configuration Country B -Region --Hospital name 1 --Hospital name 2

Or sometimes Country A --Hospital name 3 --Hospital name 4

I would like to get the country name (available in the country page of country pagetype) from my hospital page considering as shown below that the structure is not always the same. Is is possible to specify the type of the parent we are looking for without specifying the depth of our search?

Thank you, Sylvain

Recent Answers


Eugene Paden answered on April 12, 2022 17:35 (last edited on April 12, 2022 17:35)

you can use DocumentQuery and filter based on the page type and country value of the parent pages.

Check if the Path or Where method is enough for your needs: https://docs.xperience.io/custom-development/working-with-pages-in-the-api/reference-documentquery-methods

Or check the Where condition methods in this document and use the appropriate one. http://devnet.kentico.com/docs/13_0/api/html/Methods_T_CMS_DocumentEngine_DocumentQuery.htm

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.