Expand my Community achievements bar.

SOLVED

SQL2 Query for Finding Adaptive Image Components inside Templates

Avatar

Level 4

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?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @StrawHatM23 

 

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'

 

 

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Hi @StrawHatM23 

 

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'

 

 

Avatar

Community Advisor

Hi @StrawHatM23,

 

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!!

Avatar

Administrator

@StrawHatM23 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