我在liferay中创建的结构如下图所示:
{
"availableLanguageIds": [
"en_US"
],
"defaultLanguageId": "en_US",
"fields": [
{
"label": {
"en_US": "Image"
},
"predefinedValue": {
"en_US": ""
},
"style": {
"en_US": ""
},
"tip": {
"en_US": "Upload the image to be displayed in the Small Banner"
},
"dataType": "image",
"fieldNamespace": "ddm",
"indexType": "keyword",
"localizable": true,
"name": "smallImage",
"readOnly": false,
"repeatable": true,
"required": true,
"showLabel": true,
"type": "ddm-image",
"nestedFields": [
{
"label": {
"en_US": "Priority of Image"
},
"predefinedValue": {
"en_US": "0"
},
"style": {
"en_US": ""
},
"tip": {
"en_US": "Priority of the uploaded Image. Lower the number, higher the priority."
},
"dataType": "integer",
"fieldNamespace": "ddm",
"indexType": "keyword",
"localizable": true,
"name": "imagePriority",
"readOnly": false,
"repeatable": false,
"required": true,
"showLabel": true,
"type": "ddm-integer"
}
]
}
]
}
现在在模板中,我想使用图像的优先级字段对其进行排序。我的模板如下图所示:
<div id="example2" class="slider-pro">
<div class="sp-slides">
<#if smallImage.getSiblings()?has_content>
<#list smallImage.getSiblings()?sort_by(["properties","imagePriority"]) as cur_smallImage>
<#if cur_smallImage.getData()?? && cur_smallImage.getData() != "">
<div class="sp-slide">
<img class="sp-image" alt="${cur_smallImage.getAttribute("alt")}" src="${cur_smallImage.getData()}" data-src="${cur_smallImage.getData()}" data-retina="${cur_smallImage.getData()}" />
</div>
</#if>
</#list>
</#if>
</div>
</div>
我也尝试将 ?sort_by("cur_smallImage.imagePriority") 排序为?sort_by(" imagePriority ")但它没有用。我想按指定的优先级顺序显示图像。
请帮忙。