Highlighted

How to get a list of components which are present on a page

Avatar

Avatar

ssharma48

Avatar

ssharma48

ssharma48

09-04-2019

Hi all,

We have a requirement where need to extract the list of components which are present on the page at Runtime via a Page Model. If anyone has implemented the same please share the sample.

Thank you.

Shikha

Replies

Highlighted

Avatar

Avatar

Gaurav-Behl

MVP

Total Posts

1.1K

Likes

226

Correct Answer

281

Avatar

Gaurav-Behl

MVP

Total Posts

1.1K

Likes

226

Correct Answer

281
Gaurav-Behl
MVP

09-04-2019

You could follow the OOB code for "Content Tree" implementation in author or otherwise, get the page node and iterate over each node and find "sling:resourceType"

You'd have to customize based on your use case either client side or server side.

1729563_pastedImage_0.png

Highlighted

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

958

Correct Answer

820

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

958

Correct Answer

820
Arun_Patidar
MVP

10-04-2019

Hi,

You can write JCR Queries(XPATH, SQL2 or QueryBuilder) to find out node with sling:resourceType under Page:content node of a page.