I'm about to touch up my archive page. At the top I would like to insert the most commented entry of the month and below every other entry of the particular month (as usual).
I realized, that there was a plugin for popular entries, but not as event plugin.
Therefore I'm working on a solution and started with a modifier, recognizing whether one is on an archive page (which works just fine). On archive pages the entry with most comments is recognized and some entry parameters saved in variable $mostcommented (also working).
What I can't figure out whether there is a way of using $mostcommented before it is actually assigned. scope (parent | root | global) didn't make a difference.
in entries.tpl:
Code: Select all
{assign var="entry_type" value=$smarty.server.REQUEST_URI|check_entryType}
{if $entry_type eq "archiv"}
<h2 class="serendipity_date">am meisten kommentiert</h2>
Test: {$mostcommented.title}
{/if}
{include file="entries_full.tpl"}
Code: Select all
{assign var="mycommentcount" value=0}
{foreach from=$entries item="dategroup"}
{foreach from=$dategroup.entries item="entry"}
{assign var="entry" value=$entry scope="root"}
{if $entry_type eq "archiv" && $entry.comments > $mycommentcount}
{assign var="mycommentcount" value=$entry.comments}
{assign var="mostcommented" value=['comments'=>$entry.comments,'timestamp'=>$dategroup,'title'=>$entry.title] scope="parent"}
{/if}
...
{/foreach}
{/foreach}
Thanks for your time!