Liferay freemarker模板 - 在列表中使用索引

时间:2016-10-13 12:00:25

标签: liferay liferay-6 freemarker

我正在使用Liferay 6.2 EE。我想通过执行以下代码片段来检索freemarker Webcontent-Template中我的列表元素的索引:

 <#list cross_sellings_header.crossSellingsTile.getSiblings() as cross_selling>
         ${cross_selling?index}
         .... <#-- some implementation -->      
 </#list>

但是我收到一条错误消息:

Error on line 214, column 42, in template 20155#20195#ESHOP ARTIKEL Found index, expecting one of: chunk, is_date, is_hash, float, matches, time, number_to_datetime, byte, substring, is_transform, web_safe, iso_ms_nz, groups, seq_contains, iso, is_method, eval, iso_ms, iso_utc_m_nz, parent, capitalize, number, if_exists, is_directive

我也试过index_of但没有成功......

1 个答案:

答案 0 :(得分:2)

不推荐?index,正确的语法为:

${cross_selling_index}

来源: Freemarker list documentation