I am using Sightly with Sling 8 ( not AEM ). I have the following template:
<div data-sly-list.child="${resource.listChildren}">
${child.name} | ${child.path} | ${child.properties['jcr:title'] || 'no title'}
</div>
The output ( for a single child ) is
hello_world | /content/blog/posts/hello_world | no title
I know there is a jcr:title property on the child resource as I have confirmed it using an HTTP call.
How can I access the properties on the child
object?
The
child
is a Resource which does not have getProperties() but hasgetValueMap()
, so you should use:Note 1: Colons are allowed in variable names to support typical JCR names like
jcr:title
.Note 2: getValueMap() is only available since Sling API 2.7.0 bundle, previously only
resource.adaptTo(ValueMap.class)
was possible, which the expression language in sightly does not support, and this workaround was required: AEM 6.0 Sightly Child Nodes