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

Learn more

View all

Sign in to view all badges

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)

Junnu_ravali
Level 2
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.

 

4 Replies
Arun_Patidar
Community Advisor
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.

Junnu_ravali
Level 2
Level 2

Hi @Arun_Patidar 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)

Arun_Patidar
Community Advisor
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.