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

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.

Avatar

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)

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.