freemarker - Sort by nested field value in FTL liferay -


my structure created in liferay shown below:

{     "availablelanguageids": [         "en_us"     ],     "defaultlanguageid": "en_us",     "fields": [         {             "label": {                 "en_us": "image"             },             "predefinedvalue": {                 "en_us": ""             },             "style": {                 "en_us": ""             },             "tip": {                 "en_us": "upload image displayed in 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 uploaded image. lower number, higher priority."                     },                     "datatype": "integer",                     "fieldnamespace": "ddm",                     "indextype": "keyword",                     "localizable": true,                     "name": "imagepriority",                     "readonly": false,                     "repeatable": false,                     "required": true,                     "showlabel": true,                     "type": "ddm-integer"                 }             ]         }     ] } 

now in template want sort using priority field of image. template shown below:

<div id="example2" class="slider-pro">     <div class="sp-slides">         <#if smallimage.getsiblings()?has_content>             <#list smallimage.getsiblings()?sort_by(["properties","imagepriority"]) 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> 

i tried sorting ?sort_by("cur_smallimage.imagepriority") ?sort_by("imagepriority") didnt work. want display images in sequence of priority specified.
please help.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -