How to check if child component resource exist or not using Sightly in AEM?

久未见 提交于 2019-12-08 05:42:21

问题


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>


来源:https://stackoverflow.com/questions/54419352/how-to-check-if-child-component-resource-exist-or-not-using-sightly-in-aem

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!