Accessing nested properties via sightly | Community
Skip to main content
November 24, 2016
Solved

Accessing nested properties via sightly

  • November 24, 2016
  • 4 replies
  • 4235 views

Happy Thanksgiving! I shouldn't be working but this issue is driving me nuts and I'd love to figure this out.

I have a use java class that has a method called getPage. The code is below. The idea is to get all the child page underneath the page where this component lives. 

public List<Page> getPage() { List<Page> results = new ArrayList<Page>(); Iterator<Page> children = getCurrentPage().listChildren(); while (children.hasNext()) { Page child = children.next(); results.add(child); } return results; }

I call it in my component like so

<div class="directory"> <div class="row" data-sly-list.childPage="${comp.page}"> <div class="small-6 medium-3 large-3 columns"> <a href="${childPage.path}"> <img src="#nestedProperty"> <h4>${childPage.title}</h4> </a> </div> </div> </div>

tile and path work great, but I'd like to call a nested property. Here's the nested property (slide1FileReference) I'm talking about.

I found some documenation online and tried this but it doesn't work

<img src="${childPage.properties[root/c1_leadspace_carouse/slide1FileReference]}">
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by squid267

Missing quotes -__-

 

<img src="${childPage.properties['root/c1_leadspace_carouse/slide1FileReference']}">

4 replies

squid267AuthorAccepted solution
November 24, 2016

Missing quotes -__-

 

<img src="${childPage.properties['root/c1_leadspace_carouse/slide1FileReference']}">
Feike_Visser1
Adobe Employee
Adobe Employee
November 24, 2016

The way you access the properties is correct.

Can you share a package or so?

squid267Author
November 24, 2016

I was missing the single quotes! All good now thanks for commenting on the holiday!

Feike_Visser1
Adobe Employee
Adobe Employee
November 24, 2016

Indeed the quotes :-)

BTW: No Java is needed here.

<div class="directory">
        <div class="row" data-sly-list.childPage="${currentPage.listChildren}">
            <div class="small-6 medium-3 large-3 columns">
                <a href="${childPage.path}">
                    <h4>${childPage.title}</h4>
                    <h4>${childPage.properties['cq:template']}</h4>
                </a>
            </div>
        </div>
    </div>