Forum Discussion

nickyates's avatar
nickyates
Mentor
12 years ago

sorting forum posts by the number of messages in each post

Hi,   I have a category called help (categories/id/5678).  Within help there are several 7 forums.  I would like to display the names of the forums along with how many messages in total there are i...
  • nickyates's avatar
    nickyates
    12 years ago

    Hi Yuri,

     

    That was exactly what i was after, i did make one small change, i added in ?number after /messages/count").value as it was treating the numbers as text and was putting the boards in a slightly wrong order.

     

    <#assign boards = rest("categories/id/5678/boards").boards/>

    <#assign order_list = []/>
    <#list boards.board as c>
    <#assign one_index_obj = {"count":rest("/boards/id/${c.id}/messages/count").value?number, "spot":c_index}/>
    <#assign order_list = order_list + [one_index_obj]/>
    </#list>

    <#list order_list?sort_by("count")?reverse as list_item>
    ${list_item.count}:${list_item.spot}<p>
    ${boards.board[list_item.spot].title}<p>
    </#list>

     

    Thanks Yuri, this has been a massive help