Forum Discussion

bhupen's avatar
bhupen
Advisor
10 years ago

How to show highest reply posts?

Hi guyz

i want to show higest reply topic in my platform. I can show using API V1 but iam not sure about API V2 query. Following is the query I need to confirm only sql query in it. rest of code is fine i think also I need to show only 5 topic:

 

<h3>Higest Reply Topic</h3> <br />            

/*  need to correct folowing query */
<#assign restadmin("/search/messages/?q=is_root:true&sort_by=-replies").messages.message as recent />
                  <#list messages.data.items as recent >
                            <#if recent??>
                            <a href="${recent.view_href}">${recent.subject}</a><br/>
                            </#if>
                 </#list>

  • hi guys,

     

    I got the solution and posting here to help other: I have used API V2 method to achive this.  I showed only top 5 post who have most reply:

     

            <h3>Trending Post or Post who have higest reply</h3> <br />
                <#assign messages = rest("2.0","/search?q=" + "SELECT * FROM messages WHERE replies.count(*)>0 AND depth=0 order by replies.count(*) desc LIMIT 5"?url) />
            <#if messages.data.items??>                
                            <#list messages.data.items as recent >
                                <#if recent?has_content>
                                    <a href="${recent.view_href}">${recent.subject}</a><br/>
                                </#if>                           
                        </#list>
                    </#if>

1 Reply

  • hi guys,

     

    I got the solution and posting here to help other: I have used API V2 method to achive this.  I showed only top 5 post who have most reply:

     

            <h3>Trending Post or Post who have higest reply</h3> <br />
                <#assign messages = rest("2.0","/search?q=" + "SELECT * FROM messages WHERE replies.count(*)>0 AND depth=0 order by replies.count(*) desc LIMIT 5"?url) />
            <#if messages.data.items??>                
                            <#list messages.data.items as recent >
                                <#if recent?has_content>
                                    <a href="${recent.view_href}">${recent.subject}</a><br/>
                                </#if>                           
                        </#list>
                    </#if>