【问题标题】:Is there a way to generate a unique resource name in AEM?有没有办法在 AEM 中生成唯一的资源名称?
【发布时间】:2020-08-30 20:16:01
【问题描述】:

我在 tbody 中创建了一个包含列表的表格。它将生成许多行。但是,我必须使 resource name 每行都独一无二。对此有何想法?

    <table>
            <thead>
                <tr>
                    <td></td>
                </tr>
            </thead>
            <tbody data-sly-list="${itemCount}">
                <tr>
                    <td>
                        <div data-sly-resource="${'resourceName' @ resourceType='components/content/mycomponent'}"></div>
                    </td>
                </tr>
            </tbody>
        </table>

【问题讨论】:

    标签: model osgi sling sightly aem-6


    【解决方案1】:

    我不确定我明白你打算在那里做什么。您似乎想生成唯一的合成资源名称。

    为此,您可以使用 itemList.countitemList.index 具有以下值:res1res2 ... 或 res0res1 ... 请参阅 details in the HTL specification

    您可能必须使用data-sly-set 将数字连接到文本:

            <tbody data-sly-list="${itemCount}">
                <tr>
                    <td data-sly-set.resourceName="res${itemList.count}">
                        <div data-sly-resource="${resourceName @ resourceType='components/content/mycomponent'}"></div>
                    </td>
                </tr>
            </tbody>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-17
      • 1970-01-01
      • 1970-01-01
      • 2021-08-26
      • 2016-08-24
      • 2016-12-27
      • 1970-01-01
      • 2022-11-16
      相关资源
      最近更新 更多