How to check if child component resource exist or

2019-06-09 15:13发布

问题:

my component has an embedded image component inside of it, i need to show image only if image component is authored,

Component Code:

<div class="rightSideTile tile-img col-xs-5 col-md-4">
<sly data-sly-resource="${'image' @ resourceType='test/components/content/image'}"></sly>
</div>

So i need to check resource of embedded image component authored or not

i know we can do this in Java, but how to do this in Sightly?

回答1:

This can be doable ,using ${resource['image/jcr:primaryType']},

here image is child component

<sly data-sly-test="${resource['image/jcr:primaryType']}">
<div class="col-xs-5 col-md-4">
<sly data-sly-resource="${'image' @ resourceType='test/components/content/image'}"></sly>
</div>
</sly>


标签: aem sightly