Menu

How to search and get list of all pages of a given template in AEM?

Adobe experience manager is a powerful content management tool that provides ample options to explore and manage the content. In this post, we are going to see how to search and get all the pages from AEM which are created using a given template.

The detail required to execute this process.

Project path: Path of the directory where we would want to search the pages. e.g. /content/sample/en/en_us

Template path: Path of template. e.g. /apps/sample/templates/press

Now we have prerequisite handy with us, let's move to the execution.

Step 1: Go to the below mention URL. Adjust the domain according to your domain name.

http://localhost:4502/libs/cq/search/content/querydebug.html 

Step 2: Put the following query in the "Query Builder Debugger" section

type=cq:Page

path=/content/sample/en/en_us

1_property=jcr:content/cq:template

1_property.value=/apps/sample/templates/press

p.limit=500

In the above query; type cq:Page will include the nodes that have type cq:Page. Other than that nodes will get excluded from the script. after that path under that, we want to search the pages. Then after the name of the property and property value that will be a path of the template for which we are looking.

The last line p.limit is to set the limit of the results. We may set higher to get all the results at once on the screen. 

AEM Query Builder Debugger

Now click on the search button. After that query builder will execute the query and show the result on the right side of the page under the results section. Below is the screenshot.

 

Now click on the JSON QueryBuilder Link and get the JSON of the result which later you can convert into a CSV/XLS for future references.


Hope this helps you!, do let us know in the comment section if you have any question or suggestion.

References:

https://experienceleague.adobe.com/docs/experience-manager-64/developing/platform/query-builder/querybuilder-api.html?lang=en#refining-what-is-returned


No comments:

Post a Comment