How do I access the properties of a data list item in Sightly?
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>
Exit (for one child)
hello_world | /content/blog/posts/hello_world | no title
I know there is a jcr: title property on the child resource as I validated it with an HTTP call.
How can I access the properties of an object child
?
source to share
child
is a Resource that doesn't have getProperties () but does getValueMap()
, so you have to use:
${child.valueMap.jcr:title || 'no title'}
Note 1: Colonies are allowed in variable names to support typical JCR names such as jcr:title
.
Note 2: getValueMap () is only available with Sling API 2.7.0 package, previously only possible resource.adaptTo(ValueMap.class)
which expression language is not supported and this workaround was needed: AEM 6.0 Mature Child Nodes
source to share