Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to fetch the child pages & grand child pages by using recursive method in SIGHTLY.(I already have the object which contains the list of pages from the sling model class)

Avatar

Level 2

I have an object which contains all the list of child pages & grand child pages (object - brought from the sling model class). In the component html page, I want to write the code , which display all the parent and child/grand child pages using the RECURSIVE method.

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
4 Replies

Avatar

Correct answer by
Community Advisor

Avatar

Community Advisor

Hi,

I would suggest returning the list of pages from the sling model itself.

Using HTL for this use case could be tricky.



Arun Patidar

Avatar

Level 2

Hi @arunpatidar I am returning the list of pages from the sling model itself but to print the title of my pages everytime I need to fetch from the list and print. So, I want to a fetch the child pages from the object (object - which has list of pages returned from sling)in recursive way even in sightly (Example:- by using data-sly-template)

Avatar

Community Advisor
yes, htl template will help to achieve this. you need to create two template and call one another with new page as param, like a recursion. but if are resturning the page already what is the use of page, instaeof page you can return an object which consist of page, page title and other info. and use that.


Arun Patidar