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

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

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