JMPZ
04-25-2005, 10:00 PM
I couldn't understand why nobody had created this hack yet, so I made it myself.
This allows users to filter the threads by the icon. They do this by clicking on the icon in the forum thread listing. It then only shows threads with that same post icon.
Switching between pages works, as well as using the column sort functions. It is not designed to work properly with any other sort options but it might.
When posts are filtered, a "Unfilter" link is shown in the column header for thread post icons which, when clicked, removes the filter and returns the view to page 1.
Only 1 file needs to be modified, and 2 templates.
In forumdisplay.php, find
globalize($_REQUEST, array('perpage' => INT, 'pagenumber' => INT, 'daysprune' => INT));
Replace with:
//Post icon filter hack
//globalize($_REQUEST, array('perpage' => INT, 'pagenumber' => INT, 'daysprune' => INT));
globalize($_REQUEST, array('perpage' => INT, 'pagenumber' => INT, 'daysprune' => INT, 'picon'=> INT));
//*Post icon filter hack
Find:
if ($daysprune != -1)
{
$datecut = "AND lastpost >= " . (TIMENOW - ($daysprune * 86400));
$show['noposts'] = false;
}
else
{
$datecut = '';
$show['noposts'] = true;
}
And add immediately after it:
//Post icon filter hack
if ($picon > 0 && is_numeric($picon) && $picon < 5000) { //who knows if all this is necessary - better safe than sorry
$pqr = " AND thread.iconid = '$picon' ";
$datecut .= $pqr;
} else
$picon = "";
//*post icon filter hack
Find:
$pagenav = construct_page_nav($totalthreads, "forumdisplay.php?$session[sessionurl]f=$forumid", "&sort=$sortfield&order=$sortorder&pp=$perpage&days prune=$daysprune");
Replace with:
//Post icon filter hack
// $pagenav = construct_page_nav($totalthreads, "forumdisplay.php?$session[sessionurl]f=$forumid", "&sort=$sortfield&order=$sortorder&pp=$perpage&days prune=$daysprune");
$pagenav = construct_page_nav($totalthreads, "forumdisplay.php?$session[sessionurl]f=$forumid", "&sort=$sortfield&order=$sortorder&pp=$perpage&days prune=$daysprune&picon=$picon");
//*post icon filter hack
UPDATE 1.00 TO 1.01 ADD THIS MODIFICATION
Find:
$sorturl = "forumdisplay.php?$session[sessionurl]f=$forumid&daysprune=$daysprune";
And add immediately after it:
//Post icon filter hack
if ($pqr) {
$noiconurl = $sorturl;
$sorturl .= "&picon=$picon";
}
//*post icon filter hack
Ok, for the templates, in threadbit, find:
<img src="$thread[threadiconpath]" alt="$thread[threadicontitle]" border="0" />
And replace it with:
<a href="$sorturl&picon=$thread[threadiconid]"><img src="$thread[threadiconpath]" alt="$thread[threadicontitle]" border="0" /></a>
Then in FORUMDISPLAY find:
<if condition="$show['threadicons']">
<td class="thead" colspan="2"> </td>
<else />
<td class="thead"> </td>
</if>
And replace it with:
<if condition="$show['threadicons']">
<if condition="$picon">
<td class="thead" colspan="2"><a href="$noiconurl">Unfilter</a></td>
<else />
<td class="thead" colspan="2"> </td>
</if>
<else />
<td class="thead"> </td>
</if>
It's working fine on our board. If you have any questions, just ask!
This allows users to filter the threads by the icon. They do this by clicking on the icon in the forum thread listing. It then only shows threads with that same post icon.
Switching between pages works, as well as using the column sort functions. It is not designed to work properly with any other sort options but it might.
When posts are filtered, a "Unfilter" link is shown in the column header for thread post icons which, when clicked, removes the filter and returns the view to page 1.
Only 1 file needs to be modified, and 2 templates.
In forumdisplay.php, find
globalize($_REQUEST, array('perpage' => INT, 'pagenumber' => INT, 'daysprune' => INT));
Replace with:
//Post icon filter hack
//globalize($_REQUEST, array('perpage' => INT, 'pagenumber' => INT, 'daysprune' => INT));
globalize($_REQUEST, array('perpage' => INT, 'pagenumber' => INT, 'daysprune' => INT, 'picon'=> INT));
//*Post icon filter hack
Find:
if ($daysprune != -1)
{
$datecut = "AND lastpost >= " . (TIMENOW - ($daysprune * 86400));
$show['noposts'] = false;
}
else
{
$datecut = '';
$show['noposts'] = true;
}
And add immediately after it:
//Post icon filter hack
if ($picon > 0 && is_numeric($picon) && $picon < 5000) { //who knows if all this is necessary - better safe than sorry
$pqr = " AND thread.iconid = '$picon' ";
$datecut .= $pqr;
} else
$picon = "";
//*post icon filter hack
Find:
$pagenav = construct_page_nav($totalthreads, "forumdisplay.php?$session[sessionurl]f=$forumid", "&sort=$sortfield&order=$sortorder&pp=$perpage&days prune=$daysprune");
Replace with:
//Post icon filter hack
// $pagenav = construct_page_nav($totalthreads, "forumdisplay.php?$session[sessionurl]f=$forumid", "&sort=$sortfield&order=$sortorder&pp=$perpage&days prune=$daysprune");
$pagenav = construct_page_nav($totalthreads, "forumdisplay.php?$session[sessionurl]f=$forumid", "&sort=$sortfield&order=$sortorder&pp=$perpage&days prune=$daysprune&picon=$picon");
//*post icon filter hack
UPDATE 1.00 TO 1.01 ADD THIS MODIFICATION
Find:
$sorturl = "forumdisplay.php?$session[sessionurl]f=$forumid&daysprune=$daysprune";
And add immediately after it:
//Post icon filter hack
if ($pqr) {
$noiconurl = $sorturl;
$sorturl .= "&picon=$picon";
}
//*post icon filter hack
Ok, for the templates, in threadbit, find:
<img src="$thread[threadiconpath]" alt="$thread[threadicontitle]" border="0" />
And replace it with:
<a href="$sorturl&picon=$thread[threadiconid]"><img src="$thread[threadiconpath]" alt="$thread[threadicontitle]" border="0" /></a>
Then in FORUMDISPLAY find:
<if condition="$show['threadicons']">
<td class="thead" colspan="2"> </td>
<else />
<td class="thead"> </td>
</if>
And replace it with:
<if condition="$show['threadicons']">
<if condition="$picon">
<td class="thead" colspan="2"><a href="$noiconurl">Unfilter</a></td>
<else />
<td class="thead" colspan="2"> </td>
</if>
<else />
<td class="thead"> </td>
</if>
It's working fine on our board. If you have any questions, just ask!