SQL2 Query for Finding Adaptive Image Components inside Templates | Community
Skip to main content
Level 3
May 1, 2024
Solved

SQL2 Query for Finding Adaptive Image Components inside Templates

  • May 1, 2024
  • 3 replies
  • 663 views

Hi, 

 

I am trying to create a SQL2 query that will find all of the adaptive image components that are being uses inside our vehicle detail templates. 

Right now I have this as for my query. 

 

SELECT * FROM [cq:Page] AS s WHERE ISDESCENDANTNODE([/content]) AND [jcr:content/cq:template] LIKE '/apps/gm/templates/vehicledetail'

 

but I am not sure how I can query the component into this. 

 

Any suggestions?

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 gkalyan

Hi @justinbr17 

 

To find all adaptive image components used within your vehicle detail templates, you’ll need to adjust your SQL2 query to target the specific sling:resourceType of the adaptive image components.
 
Something like this might help
 

 

SELECT * FROM [nt:unstructured] AS node node.[sling:resourceType] = 'gm/components/content/adaptiveimage'

 

 

3 replies

gkalyan
Community Advisor and Adobe Champion
gkalyanCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
May 1, 2024

Hi @justinbr17 

 

To find all adaptive image components used within your vehicle detail templates, you’ll need to adjust your SQL2 query to target the specific sling:resourceType of the adaptive image components.
 
Something like this might help
 

 

SELECT * FROM [nt:unstructured] AS node node.[sling:resourceType] = 'gm/components/content/adaptiveimage'

 

 
sravs
Community Advisor
Community Advisor
May 2, 2024

Hi @justinbr17,

 

Try executing below query, this helps to find all the pages created using vehicle detail template and having the adaptive image component in it.

 

select page.[jcr:path] from [cq:Page] AS page INNER JOIN [cq:PageContent] AS jcrContent ON ISCHILDNODE(jcrContent, page) INNER JOIN [nt:unstructured] AS child ON ISDESCENDANTNODE(child, jcrContent) where ISDESCENDANTNODE(page, '/content') and jcrContent.[cq:template] LIKE '/apps/gm/templates/vehicledetail' and child.[sling:resourceType] = 'project/components/adaptiveImage'

Hope this helps!!

kautuk_sahni
Community Manager
Community Manager
May 16, 2024

@justinbr17 Did you find the suggestion helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni