问题描述
我需要仔细检查列表的大小.我尝试了resource.size,item.size,itemList.size,resource.listChildren.size,item.listChildren.size,但是这些都不起作用.
I need to check the size of list in sightly. I have tried resource.size, item.size, itemList.size, resource.listChildren.size, item.listChildren.size, but none of these works.
我打算使用Java USE-API,但是我不知道如何开始.
I'm planning to use Java USE-API, but I have no clue how to start.
<sly data-sly-list="resource.listChildren">
<sly data-sly-list="item.listChildren">
${itemList.count} / #I need the total count of item here#
</sly>
</sly>
推荐答案
资源#listChildren 将返回Iterator<Resource>
,您将无法从那里获取子列表的大小.
Since Resource#listChildren will return an Iterator<Resource>
, you will not be able to get the size of the list of children from there.
HTL也不提供获取列表大小的方法,但是它允许获取当前商品的有趣属性:
HTL does not offer a way to get the list size either, however it allows getting interesting properties of the current item:
* index: zero-based counter (0..length-1);
* count: one-based counter (1..length);
* first: true for the first element being iterated;
* middle: true if element being iterated is neither the first nor the last;
* last: true for the last element being iterated;
* odd: true if count is odd;
* even: true if count is even.
这篇关于如何找到可见清单的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!