Advertisement:

Author Topic: Sort posts by date posted, not by most recent reply  (Read 27866 times)

Offline ipggi

  • Semi-Newbie
  • *
  • Posts: 42
Sort posts by date posted, not by most recent reply
« 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

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male

Offline A.M.A

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,133
  • Gender: Male
  • ..
Re: Sort posts by date posted, not by most recent reply
« Reply #2 on: October 10, 2004, 07:19:44 PM »
Really sorry .. real life is demanding my full attention .. will be back soon hopefully :)

Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Re: Sort posts by date posted, not by most recent reply
« Reply #3 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
« Last Edit: October 10, 2004, 10:19:17 PM by Anguz »
Cristián Lávaque http://cristianlavaque.com

Offline A.M.A

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,133
  • Gender: Male
  • ..
Re: Sort posts by date posted, not by most recent reply
« Reply #4 on: October 11, 2004, 04:23:58 AM »
In that case Anguz ..

in MessageIndex.template.php look for:
Code: [Select]
<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:
Code: [Select]
<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:
Code: [Select]
<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:
Code: [Select]
<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 :)

Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Re: Sort posts by date posted, not by most recent reply
« Reply #5 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. ;)
Cristián Lávaque http://cristianlavaque.com

Offline ipggi

  • Semi-Newbie
  • *
  • Posts: 42
Re: Sort posts by date posted, not by most recent reply
« Reply #6 on: October 16, 2004, 10:09:53 PM »
went in like a knife in butter.   ;D
« Last Edit: October 16, 2004, 10:29:02 PM by ipggi »

Offline Isaac

  • Sophist Member
  • *****
  • Posts: 1,140
  • Gender: Male
    • Funky Arcade
Re: Sort posts by date posted, not by most recent reply
« Reply #7 on: June 28, 2005, 06:12:20 PM »
How would you go about making the 'date started' the one sorted by Default?

Offline Isaac

  • Sophist Member
  • *****
  • Posts: 1,140
  • Gender: Male
    • Funky Arcade
Re: Sort posts by date posted, not by most recent reply
« Reply #8 on: July 18, 2005, 02:35:17 AM »
Anybody? :)

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Sort posts by date posted, not by most recent reply
« Reply #9 on: July 19, 2005, 10:40:47 PM »

Offline Isaac

  • Sophist Member
  • *****
  • Posts: 1,140
  • Gender: Male
    • Funky Arcade
Re: Sort posts by date posted, not by most recent reply
« Reply #10 on: July 19, 2005, 11:18:17 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...

Offline gri

  • Full Member
  • ***
  • Posts: 553
  • Space Human
Re: Sort posts by date posted, not by most recent reply
« Reply #11 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".