Forum Discussion

LauraB's avatar
LauraB
Genius
14 years ago

most read articles

Hello everyone!

 

I'm wanting to pull the most read articles from a specific label into a widget to be displayed on a separate page than the blog itself - has anyone had any success coding this type of functionality before?  Lots of blogs use this as a "hot topics" type of feature. Considered using top kudoed, but we don't allow non-members to kudo articles, so thought that article views would be a better way to measure "hotness" in this case.

 

Thanks!

1 Reply

  • Assuming you have a widget container setup, I think this would work for you.

     

    <#assign view_threshold = 100 />
    <#list rest("/blogs/id/MYBLOG/posts/for/labels/text/MYLABEL").node_message_context.message as message>
      <#if (message.views.count?number > view_threshold)>
        <li><a href="${message.@view_href}">${message.subject}</a></li>
      </#if>
    </#list>

     

    Where MYBLOG is your blog ID and MYLABEL is the desired label.  You'll want to adjust the view_threshold value, too.  This should print one blog entry per row in an HTML list.