How to check if child component resource exist or

2019-06-09 14:49发布

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?

标签: aem sightly
1条回答
不美不萌又怎样
2楼-- · 2019-06-09 15:27

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>
查看更多
登录 后发表回答