Forum Discussion

vishwajeet_hol's avatar
10 years ago

Sort the posts by the number of views to that topic

Hi,

 

I am trying to sort posts by no. of views.

 

Just tried below code by referering one of the post on lithosphere, but it doesn't works :

http://community.lithium.com/t5/Developers-Discussion/sorting-forum-posts-by-the-number-of-messages-in-each-post/m-p/199561#M8702

 

 

<#assign thread_list=rest("/boards/id/<board_ID>/threads").threads.thread/>
<ul>
<#list thread_list?sort_by(['messages','views','count'])?reverse as thread>
<li>${thread.id}</li>
</#list>
</ul>   

 Let me know if there is any way.

 

Thank you.

 

Regards,

Vishwajeet

 

  • vishwajeet_hol Updated your code a bit, see if this works

     

    <#assign thread_list=rest("/boards/id/<board_ID>/threads").threads/>
    <ul>
    <#list thread_list.thread?sort_by(['messages','topic','views','count'])?reverse as thread>
    <li>${thread.id}</li>
    </#list>
    </ul>  

     

     

5 Replies