tgmorris
01-26-2005, 10:00 PM
A few people have been asking for a way to sort forums by the date the thread was originally posted. Here's a quick change to allow the capability to sort the threads in a forum in either ascending or descending date order.
I've tested this against 3.0.3 but it should work fine using 3.0.6.
In forumdisplay.php find the following and insert the highlighted line.
switch ($sortfield)
{
case 'title':
$sqlsortfield = 'thread.title';
break;
case 'lastpost':
case 'replycount':
case 'views':
case 'postusername':
case 'dateline':
$sqlsortfield = $sortfield;
break;
case 'voteavg':
if ($foruminfo['allowratings'])
{
$sqlsortfield = 'voteavg';
break;
} // else, use last post
default:
$sqlsortfield = 'lastpost';
$sortfield = 'lastpost';
}
In the FORUMDISPLAY template find the following and add the highlighted portion. Be sure to add the " / " on the line above newly added line.
<td class="thead" width="100%">
<if condition="$show['threadratings']"><span style="float:$stylevar[right]"><a href="$sorturl&order=desc&sort=voteavg">$vbphrase[rating]</a> $sortarrow[voteavg]</span></if>
<a href="$sorturl&order=asc&sort=title">$vbphrase[thread]</a> $sortarrow[title] /
<a href="$sorturl&order=asc&sort=postusername">$vbphrase[thread_starter]</a> $sortarrow[postusername] /
<a href="$sorturl&order=asc&sort=dateline">Thread Date</a> $sortarrow[dateline]
</td>
As always, back up any files you will be changing.
What it does:
Adds the " / Thread Date" link to the fourm header - see the attached image. This allows the forum to be sorted by ascending date. Once selected the standard sort arrow will appear and allow the order to be changed to descending.
I've tested this against 3.0.3 but it should work fine using 3.0.6.
In forumdisplay.php find the following and insert the highlighted line.
switch ($sortfield)
{
case 'title':
$sqlsortfield = 'thread.title';
break;
case 'lastpost':
case 'replycount':
case 'views':
case 'postusername':
case 'dateline':
$sqlsortfield = $sortfield;
break;
case 'voteavg':
if ($foruminfo['allowratings'])
{
$sqlsortfield = 'voteavg';
break;
} // else, use last post
default:
$sqlsortfield = 'lastpost';
$sortfield = 'lastpost';
}
In the FORUMDISPLAY template find the following and add the highlighted portion. Be sure to add the " / " on the line above newly added line.
<td class="thead" width="100%">
<if condition="$show['threadratings']"><span style="float:$stylevar[right]"><a href="$sorturl&order=desc&sort=voteavg">$vbphrase[rating]</a> $sortarrow[voteavg]</span></if>
<a href="$sorturl&order=asc&sort=title">$vbphrase[thread]</a> $sortarrow[title] /
<a href="$sorturl&order=asc&sort=postusername">$vbphrase[thread_starter]</a> $sortarrow[postusername] /
<a href="$sorturl&order=asc&sort=dateline">Thread Date</a> $sortarrow[dateline]
</td>
As always, back up any files you will be changing.
What it does:
Adds the " / Thread Date" link to the fourm header - see the attached image. This allows the forum to be sorted by ascending date. Once selected the standard sort arrow will appear and allow the order to be changed to descending.