Sightly - how to get child resource

Avatar

Avatar

Jedrzej84

Avatar

Jedrzej84

Jedrzej84

15-10-2015

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 🙂

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Feike_Visser1

Employee

Avatar

Feike_Visser1

Employee

Feike_Visser1
Employee

15-10-2015

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.

Answers (4)

Answers (4)

Avatar

Avatar

sureshreddy810

Avatar

sureshreddy810

sureshreddy810

27-01-2021

how to get children by using node object

Avatar

Avatar

akashs51893872

Avatar

akashs51893872

akashs51893872

10-08-2018

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...

Avatar

Avatar

Jedrzej84

Avatar

Jedrzej84

Jedrzej84

15-10-2015

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

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

15-10-2015

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.