Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

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

ssharma48
Level 2
Level 2

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

2 Replies
Gaurav-Behl
Community Advisor
Community Advisor

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

Arun_Patidar
Community Advisor
Community Advisor

Hi,

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