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

Sightly - how to get child resource

Jedrzej84
Level 2
Level 2

Hi All,

I have searched how to get child resource from "resource" object in sightly, but haven`t found any answer.

I know that I could read property of child node, but I include parsys in my component and want to list children of parsys.

As a workaround I do

<div data-sly-list.parsys="${resource.listChildren}" data-sly-unwrap> <ul data-sly-list.item="${parsys.listChildren}"> ... process item ... </ul> </div>

 

how to have sth like:

${resource.parsys.listChildren}

 

Thanks for your help 🙂

1 Accepted Solution
Feike_Visser1
Correct answer by
Employee
Employee

There are the following methods on the Resource object:

getChild(String)

getChildren() / listChildren()

Currently sightly does not support calling a method with an argument.

If you want to do this, you need to use the use-api for this.

View solution in original post

5 Replies
smacdonald2008
Level 10
Level 10

This is covered in docs:

http://docs.adobe.com/docs/en/aem/6-0/develop/sightly.html

See:

    
<dl data-sly-list.child="${currentPage.listChildren}">
    <dt>index: ${childList.index}</dt>
    <dd>value: ${child.title}</dd>
</dl>

 

It lists children of a page as an example.

Feike_Visser1
Correct answer by
Employee
Employee

There are the following methods on the Resource object:

getChild(String)

getChildren() / listChildren()

Currently sightly does not support calling a method with an argument.

If you want to do this, you need to use the use-api for this.

View solution in original post

Jedrzej84
Level 2
Level 2

Thanks for the clarification, I would go with additional Sling Model for it.

akashs51893872
Level 3
Level 3

This might work in this case:

<sly data-sly-use.parsys="${resource.path}/parsys" data-sly-list="${parsys.listChildren}">
     <pre>${item.name}</pre>
</sly>

We can work with resources with data-sly-use.

Good Luck...

sureshreddy810
Level 1
Level 1

how to get children by using node object