News:

Wondering if this will always be free?  See why free is better.

Main Menu

Sort posts by date posted, not by most recent reply

Started by ipggi, October 10, 2004, 01:34:28 PM

Previous topic - Next topic

ipggi

How would I go about adding a column to the message index that shows the date the thread was originally started, and then allow users to sort by that date?

right now as you know it's listed as:
   Subject   Started by   Replies   Views   Last post

I would like it to be listed as:
   Subject   Started by   Started On   Replies   Views   Last post


A.M.A

Really sorry .. real life is demanding my full attention .. will be back soon hopefully :)

Anguz

#3
A.M.A, I don't think he was talking about sorting it by default with first post, but that mod will certainly help him with that if that's the case. ;)

ipggi, [Unknown]'s reply shows how you sort by date the topic was started (time of the first post, actually), you add ;sort=first_post to the board's URL.

You're still missing how to get the date/time to display in the new column for each topic. I don't know off the bat, but someone like [Unknown] will probably be able to tell you before I find it. :P
Cristián Lávaque http://cristianlavaque.com

A.M.A

In that case Anguz ..

in MessageIndex.template.php look for:
<td width="9%" colspan="2"></td>
<td><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=subject', $context['sort_by'] == 'subject' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[70], $context['sort_by'] == 'subject' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="14%"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=starter', $context['sort_by'] == 'starter' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[109], $context['sort_by'] == 'starter' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="4%" align="center"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=replies', $context['sort_by'] == 'replies' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[110], $context['sort_by'] == 'replies' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="4%" align="center"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=views', $context['sort_by'] == 'views' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[301], $context['sort_by'] == 'views' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="22%"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=last_post', $context['sort_by'] == 'last_post' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[111], $context['sort_by'] == 'last_post' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>';

replace it with:
<td width="9%" colspan="2"></td>
<td><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=subject', $context['sort_by'] == 'subject' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[70], $context['sort_by'] == 'subject' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="8%"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=starter', $context['sort_by'] == 'starter' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[109], $context['sort_by'] == 'starter' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
                                        <td width="15%"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=first_post', $context['sort_by'] == 'first_post' && $context['sort_direction'] == 'up' ? ';desc' : '', '">Started On', $context['sort_by'] == 'first_post' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="4%" align="center"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=replies', $context['sort_by'] == 'replies' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[110], $context['sort_by'] == 'replies' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="4%" align="center"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=views', $context['sort_by'] == 'views' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[301], $context['sort_by'] == 'views' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="15%"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=last_post', $context['sort_by'] == 'last_post' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[111], $context['sort_by'] == 'last_post' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>';


look for:
<span class="smalltext">', $topic['pages'], '</span>
</td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '
</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '
</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '
</td>
<td class="windowbg2" valign="middle" width="22%"><span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span></td>';

replace it with:
<span class="smalltext">', $topic['pages'], '</span>
</td>
<td class="windowbg2" valign="middle" width="8%">
', $topic['first_post']['member']['link'], '
</td>
<td class="windowbg2" valign="middle" width="10%"><span class="smalltext">
', $topic['first_post']['time'], '
</span></td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '
</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '
</td>
<td class="windowbg2" valign="middle" width="20%"><span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span></td>';


note that you may need to change the width of the <td>s
Really sorry .. real life is demanding my full attention .. will be back soon hopefully :)

Anguz

$topic['first_post']['time']

Already available, very cool. I was planning to add this to my template as well.

Thanks. ;)
Cristián Lávaque http://cristianlavaque.com

ipggi

#6
went in like a knife in butter.   ;D

Isaac

How would you go about making the 'date started' the one sorted by Default?

Isaac



Isaac

Quote from: [Unknown] on July 19, 2005, 10:40:47 PM
Board Default Sort?

-[Unknown]
Doesn't work with SMF 1.0.5 :(
Maybe I'll have a look at the mod file and see if it I can install it manually...

gri

ipggi,
what about renaming the topic to
"Sort topics by date posted, not by most recent reply" ?

Do not ~relevane~ it with "Sort posts".

DIAR


Suki

Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Advertisement: