Is it possible to sort comments first on top
-
FinnK
Is it possible to sort comments first on top
Is it possible to sort comments first on top and new comments at the bottom?
-
pgoneill
Re: Is it possible to sort comments first on top
I'm wondering this very thing. If anyone knows of a way to reverse the sorting of the comments, I'm all ears! 
-
pgoneill
Re: Is it possible to sort comments first on top
OK, so I'll take that as a no. 
Here's what I'm trying now in the comments display template (trying to "fake it" by getting a descending set of numbers to make the reader aware which is the first item, since the module spits them out backwards):
Obviously, this doesn't work. Otherwise I wouldn't need to post it.
If anyone can provide a suggestion...basically I need to find the length of the $items array and use that as the start of the counter.
Here's what I'm trying now in the comments display template (trying to "fake it" by getting a descending set of numbers to make the reader aware which is the first item, since the module spits them out backwards):
Code: Select all
<dl>
{php}$initialize = count($items);{/php}
{foreach from=$items item=entry}
<dt class="clearfix">
<span class="counter">{counter start="$initialize" direction='down'}</span>
{if $entry->author_email}
<a href="mailto:{$entry->author_email|escape:"hexentity"}">{$entry->comment_author}</a>
{else}
{$entry->comment_author}
{/if}
said...<br /><span class="date">{$entry->date}</span></dt>
<dd>{$entry->comment_data}</dd>
{/foreach}
</dl>If anyone can provide a suggestion...basically I need to find the length of the $items array and use that as the start of the counter.
Last edited by pgoneill on Fri Dec 01, 2006 9:15 pm, edited 1 time in total.
Re: Is it possible to sort comments first on top
Looking at the source code of action.default.php it seems the comments are retrieved with this query:
Change
at the end of that line to
and they should show the other way around.
Regards,
D
Code: Select all
$query = "SELECT comment_id, comment_author, comment_data, comment_date, author_email, author_website FROM ".cms_db_prefix()."module_comments WHERE page_id = ".$pageid." AND module_name = '".$modulename."' AND active = 1 ORDER BY comment_date desc";
Code: Select all
ORDER BY comment_date descCode: Select all
ORDER BY comment_date ascRegards,
D
-
pgoneill
Re: Is it possible to sort comments first on top
Sweet.
I ended up faking it (showing a descending series of numbers) by assigning a variable to smarty:
and then:
Your way is much better, though. 
I ended up faking it (showing a descending series of numbers) by assigning a variable to smarty:
Code: Select all
$initializecount = count($entryarray);
$this->smarty->assign_by_ref('initializecount', $initializecount);Code: Select all
{foreach from=$items item=entry}
<dt class="clearfix"><span class="counter">{$initializecount}</span>{if $entry->author_email}<a href="mailto:{$entry->author_email|escape:"hexentity"}">{$entry->comment_author}</a>
{else}{$entry->comment_author}{/if} said...<br /><span class="date">{$entry->date}</span></dt>
<dd>{$entry->comment_data}</dd>
{assign var=initializecount value=$initializecount-1}
{/foreach}
