Daily Archives: July 6, 2004

Most Popular Posts

I’ve just added a new plugin to the site that lists the most popular posts on your blog.
The command is {popularposts} which creates an array, $pposts, containing the list of posts. Unfortunately it’ll only work if you use the newer $blogid/archives/p/1/ type url, not the old $blogid/archives/m/200407/#1
Thank you Nargler for the MySQL substring_index code. Helped a lot!

Here’s an example usage:

{popularposts}
{if $pposts != ''}
  <b>Most Popular Posts</b><br />
  {foreach from=$pposts key=key item=hits}
    <nobr><a href="{$siteurl}/archives/p/{$hits.postID}/c/1/more/1" title='{$hits.title}'>{$hits.title|truncate:30:"..."}</a>: {$key}</nobr><br />
  {/foreach}
{/if}