HTL/Sightly: How to access individual values in an array? (not sure if it's an array) | Community
Skip to main content
jayv25585659
New Participant
November 8, 2017
Solved

HTL/Sightly: How to access individual values in an array? (not sure if it's an array)

  • November 8, 2017
  • 2 replies
  • 3118 views

So I have the code below (which I got from Sightly how to get multivalued properties )

<dl data-sly-list.head="${properties.testimonials}">

    <dt>key: ${head}</dt>

</dl>

and this gives me

key: {"testimonialPath":"/content/myhost/en/testimonials/hr/about"}
key: {"testimonialPath":"/content/myhost/en/testimonials/hr/work-safety"}
key: {"testimonialPath":"myhost/en/testimonials/hr/vacancy"}
How can I access the values that start with"/content"?
I tried
<dl data-sly-list.head="${properties.testimonials}">
    <dt>key: ${head[testimonialPath]}</dt>
</dl>

And my page won't load because of an error. I then tried

<dl data-sly-list.head="${properties.testimonials}">
    <dt>key: ${head["testimonialPath"]}</dt>
</dl>

and while there's no error, I also doesn't display the value.

Can you please help? Thanks!

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 smacdonald2008

If you want to return only values that start with /content - i recommend using Java business logic to filter the ArrayList and then display those values.

2 replies

smacdonald2008
smacdonald2008Accepted solution
New Participant
November 8, 2017

If you want to return only values that start with /content - i recommend using Java business logic to filter the ArrayList and then display those values.

smacdonald2008
New Participant
November 8, 2017

See this article where we work with Collections and HTL. The Java part of the HTL returns a Java collection and the HTL iterates over it and renders the values:

Scott's Digital Community: Creating an Adobe Experience Manager HTL component that displays a repeating data set

<div data-sly-test="${ibeanObj.lBean}" data-sly-list.items="${ibeanObj.lBean}">

                  <div style="height:250px;"><img src=${items.path} height=200 width=270 style="padding:4px"/><h2>${items.page}</h2>

                             <p>${items.desc}</p>

                                

                             </div>

                             <hr>

                    </div>