Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: ipggi on October 10, 2004, 01:34:28 PM

Title: Sort posts by date posted, not by most recent reply
Post by: ipggi on October 10, 2004, 01:34:28 PM
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
Title: Re: Sort posts by date posted, not by most recent reply
Post by: [Unknown] on October 10, 2004, 06:20:09 PM
http://www.simplemachines.org/community/index.php?board=3.0;sort=first_post

-[Unknown]
Title: Re: Sort posts by date posted, not by most recent reply
Post by: A.M.A on October 10, 2004, 07:19:44 PM
hope this is what you are looking for:
http://www.simplemachines.org/community/index.php?topic=17697.0
Title: Re: Sort posts by date posted, not by most recent reply
Post by: Anguz on October 10, 2004, 10:17:13 PM
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
Title: Re: Sort posts by date posted, not by most recent reply
Post by: A.M.A on October 11, 2004, 04:23:58 AM
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
Title: Re: Sort posts by date posted, not by most recent reply
Post by: Anguz on October 11, 2004, 06:12:27 AM
$topic['first_post']['time']

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

Thanks. ;)
Title: Re: Sort posts by date posted, not by most recent reply
Post by: ipggi on October 16, 2004, 10:09:53 PM
went in like a knife in butter.   ;D
Title: Re: Sort posts by date posted, not by most recent reply
Post by: Isaac on June 28, 2005, 06:12:20 PM
How would you go about making the 'date started' the one sorted by Default?
Title: Re: Sort posts by date posted, not by most recent reply
Post by: Isaac on July 18, 2005, 02:35:17 AM
Anybody? :)
Title: Re: Sort posts by date posted, not by most recent reply
Post by: [Unknown] on July 19, 2005, 10:40:47 PM
Board Default Sort (http://www.simplemachines.org/community/index.php?topic=17697.0)?

-[Unknown]
Title: Re: Sort posts by date posted, not by most recent reply
Post by: Isaac on July 19, 2005, 11:18:17 PM
Quote from: [Unknown] on July 19, 2005, 10:40:47 PM
Board Default Sort (http://www.simplemachines.org/community/index.php?topic=17697.0)?

-[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...
Title: Re: Sort posts by date posted, not by most recent reply
Post by: gri on September 27, 2005, 08:18:24 AM
ipggi,
what about renaming the topic to
"Sort topics by date posted, not by most recent reply" ?

Do not ~relevane~ it with "Sort posts".
Title: Re: Sort posts by date posted, not by most recent reply
Post by: DIAR on October 26, 2018, 01:32:48 PM
I just wanna know if this is working for 2.0.
Title: Re: Sort posts by date posted, not by most recent reply
Post by: Suki on October 26, 2018, 05:51:20 PM
Yes, using the exact same link provided 14 years ago:

Quote from: [Unknown] on October 10, 2004, 06:20:09 PM
http://www.simplemachines.org/community/index.php?board=3.0;sort=first_post

-[Unknown]