Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Sightly - how to get child resource

Avatar

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

Avatar

Correct answer by
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

6 Replies

Avatar

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.

Avatar

Correct answer by
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.

Avatar

Level 2

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

Avatar

Level 4

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

Level 1

how to get children by using node object