如何在AEM中使用Sightly检查子组件资源是否存在? [英] How to check if child component resource exist or not using Sightly in AEM?

查看:109
本文介绍了如何在AEM中使用Sightly检查子组件资源是否存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的组件内部有一个嵌入式图像组件,只有在创作了图像组件的情况下,我才需要显示图像,

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

组件代码:

<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

我知道我们可以用Java做到这一点,但是如何在Sightly中做到这一点?

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

推荐答案

这可以使用 $ {resource ['image / jcr:primaryType']} 来实现,

此处图像是子组件

<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检查子组件资源是否存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆