Component used in multiple places. | Community
Skip to main content
Level 2
June 30, 2020
Solved

Component used in multiple places.

  • June 30, 2020
  • 3 replies
  • 1561 views

HI Team ,

 

I  have question on AEM custom component , How can we check  how many places  AEM component is used in the content node .   If I modify that  component needs to know how many places it will reflect .   SQL2 we have the option to fetch, Please let me know if we have any solution for this. 

 

 

Thanks 

Hari Chandana. 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by vanegi

Hi Hari,

A xpath query can be used to get the results where this component is used.

Goto CRXDELight using http://AEM-AUTHOR-HOST/crx/de/index.jsp, open Tools -> Query. Place the query into the Query box:

/jcr:root/content//*[jcr:contains(@sling:resourceType, 'COMPONENT_NAME/PATH')] order by @jcr:score

if you know exact path of the component then use below query.

/jcr:root/content//*[@sling:resourceType =  'COMPONENT_PATH'] order by @jcr:score 

It will return list of paths of content nodes where your component being used. You may split the each path before /jcr:content to get exact page paths.

 

Thanks,

Vaishali

3 replies

Varun_Shakya
Community Advisor
Community Advisor
June 30, 2020

You can use groovy script 

https://hashimkhan.in/aem-adobecq5-code-templates/groovy-script/

 You can try this Url it will give you the components list and their usage

http://localhost:4512/libs/wcm/core/content/sites/components.html

 and you have QueryBuilder to get the list of pages with particular component.

vanegi
Adobe Employee
vanegiAdobe EmployeeAccepted solution
Adobe Employee
June 30, 2020

Hi Hari,

A xpath query can be used to get the results where this component is used.

Goto CRXDELight using http://AEM-AUTHOR-HOST/crx/de/index.jsp, open Tools -> Query. Place the query into the Query box:

/jcr:root/content//*[jcr:contains(@sling:resourceType, 'COMPONENT_NAME/PATH')] order by @jcr:score

if you know exact path of the component then use below query.

/jcr:root/content//*[@sling:resourceType =  'COMPONENT_PATH'] order by @jcr:score 

It will return list of paths of content nodes where your component being used. You may split the each path before /jcr:content to get exact page paths.

 

Thanks,

Vaishali

Vijayalakshmi_S
Level 10
June 30, 2020

Hi @hari_krishnac22,

Use the below query builder predicate as a reference to list all the paths where the component is used.

path=/content/we-retail  
type=nt:unstructured //we can't use cq:Page type directly. Component under content path resides in this type (hierarchy of component differs from page to page based on where we have authored)
1_property=sling:resourceType
1_property.value=weretail/components/content/text
p.limit=-1