Adobe CQ AEM: query to fetch pages by passing component name

Saravanan picture Saravanan · Jan 26, 2016 · Viewed 9.2k times · Source

I am using Query builder as below to get the list of distinct pages which uses the component (component name will passed as a parameter) in property. I need to pass two parameters, cq:lastReplicationAction=Activate and sling:resourceType=component path. I tried above JSON query but no result and it is failing since the component may be used at any level of page node. E.g, /jcr:content/par/component or /jcr:content/par/mainpar/component

https://host:port/bin/querybuilder.json?1_property=sling:resourceType&1_property.value=COMPONENTPATH&2_property=jcr:content/cq:lastReplicationAction&2_property.value=Activate&path=FROM_WHICH_CONTENT_PATH&type=cq:Page&p.limit=-1

Answer

Mohit Bansal picture Mohit Bansal · Jan 28, 2016

Components are placed under par node of page, and Replication property is part of page JCR node. That's the reason your query is returning 0 result. Try this query:

http://localhost:4502/bin/querybuilder.json?1_property=jcr:content/par/*/sling:resourceType&1_property.value=<Component-Path>&2_property=jcr:content/cq:lastReplicationAction&2_property.value=Activate&path=<BASE-Content-Path>&type=cq:Page&p.limit=-1

I have used following property to find component: jcr:content/par/*/sling:resourceType If your par node has different name then use correct name of par node.