我可以将参数从调用 ISML 传递到内容槽吗?

Can I pass parameters to a content slot from the calling ISML?

我希望能够通过请求范围变量或其他方式将一些补充信息传递给内容槽。

我在调用 ISML 时试过这个:

<isset name="message" scope="request" value="I want to be an Air Force Ranger" />
<isslot id="slot-message" context="global" description="banner"/>

在广告位的渲染模板中我有:

<iscontent type="text/html" charset="UTF-8" compact="true"/>
<iscache type="relative" hour="24"/>
<h3>${request.custom.message}</h3>

但是,在输出 HTML 中,我只得到:

<h3>null</h3>

有什么方法可以将对象或字符串传递到内容槽吗?

内容资产无权访问创建或传递给 ISML 的数据。但是,可以通过将数据添加到 DOM 然后在内容资产中读取它来完成解决方法:

<div class="banner-data" data-message="${message}">
    <isslot id="slot-message" context="global" description="banner"/>
</div>

然后,在您的内容资产中,您可以阅读消息并使用它:

<script>
    var bannerData = $('.banner-data').data();
    var message = bannerData["message"];
</script>

内容资产不知道它们嵌入的页面。这是设计使然。但是,您可以使用 $include()$ 将 HTML 嵌入到您的内容中,它使用任何 $url-方法。

在内容模板中,还可以分别使用 ${slotcontent} 和 ${slotcontent.content} 从内容槽或内容本身引用数据。