[Comments Module] Set ascending or descending order
Posted: Sat Dec 01, 2007 7:42 pm
The question: How to make Comments render in ascending or descending order?
I'm running the latest Comments Module on CMSMS 1.4.1.1.
The module help does not list any hooks that allow you to set the order that the comments are rendered in. The short answer to my question would be if there is already a hook, that just isn't listed on the Comments Module help page. Anyone know if there is an order variable for Comments?
Assuming there is not, then my next option is to reverse the order the comments are printed in by altering the {foreach} loop in the Display Template for the Comments Module.
The original form of the loop is like this:
Since {foreach} doesn't have the flexbility to count backwards, I tried replacing it with the following {section} loop instead:
This seemed to work, as it did produce a ul with the correct number of list items. However, the items were blank.
This makes me think that changing the loop type messed up the variable calls in the body of the loop.
Does anyone have any suggestions on how to fix it?
Thanks,
Ken Griffith
I'm running the latest Comments Module on CMSMS 1.4.1.1.
The module help does not list any hooks that allow you to set the order that the comments are rendered in. The short answer to my question would be if there is already a hook, that just isn't listed on the Comments Module help page. Anyone know if there is an order variable for Comments?
Assuming there is not, then my next option is to reverse the order the comments are printed in by altering the {foreach} loop in the Display Template for the Comments Module.
The original form of the loop is like this:
Code: Select all
{foreach from=$items item=entry}
<li>
{if $entry->author_email}
<span class="author"><a class="author" href="mailto:{$enuthor_email|escape:"hexentity"}">{$entry->comment_author}</a></span>
{else}
<span class="author">{$entry->comment_author} says:</span>
{/if}
{if $entry->author_website}(<a href="{$entry->author_website}" target="_blank">{$entry->author_website}</a>){/if}
{$entry->comment_data}
<span class="date">{$entry->date}</span>
</li>
{/foreach}Code: Select all
{section loop=$item name=entry step=-1}
<li>
{if $entry->author_email}
<span class="author"><a class="author" href="mailto:{$enuthor_email|escape:"hexentity"}">{$entry->comment_author}</a></span>
{else}
<span class="author">{$entry->comment_author} says:</span>
{/if}
{if $entry->author_website}(<a href="{$entry->author_website}" target="_blank">{$entry->author_website}</a>){/if}
{$entry->comment_data}
<span class="date">{$entry->date}</span>
</li>
</section}This makes me think that changing the loop type messed up the variable calls in the body of the loop.
Does anyone have any suggestions on how to fix it?
Thanks,
Ken Griffith