PDA

View Full Version : Filter threads by post icon


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", "&amp;sort=$sortfield&amp;order=$sortorder&amp;pp=$perpage&amp;days prune=$daysprune");


Replace with:



//Post icon filter hack
// $pagenav = construct_page_nav($totalthreads, "forumdisplay.php?$session[sessionurl]f=$forumid", "&amp;sort=$sortfield&amp;order=$sortorder&amp;pp=$perpage&amp;days prune=$daysprune");
$pagenav = construct_page_nav($totalthreads, "forumdisplay.php?$session[sessionurl]f=$forumid", "&amp;sort=$sortfield&amp;order=$sortorder&amp;pp=$perpage&amp;days prune=$daysprune&amp;picon=$picon");
//*post icon filter hack


UPDATE 1.00 TO 1.01 ADD THIS MODIFICATION
Find:

$sorturl = "forumdisplay.php?$session[sessionurl]f=$forumid&amp;daysprune=$daysprune";


And add immediately after it:

//Post icon filter hack
if ($pqr) {
$noiconurl = $sorturl;
$sorturl .= "&amp;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&amp;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">&nbsp;</td>
<else />
<td class="thead">&nbsp;</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">&nbsp;</td>
</if>
<else />
<td class="thead">&nbsp;</td>
</if>


It's working fine on our board. If you have any questions, just ask!

Jolten
04-26-2005, 03:25 PM
I've wanted this for a bit, but couldn't figure it out. Thanks, this works perfectly.

HeloHi
04-27-2005, 05:02 AM
This is great :)

HeloHi
04-27-2005, 07:19 PM
where you have:

if ($daysprune != -1)
{
$datecut = "AND lastpost >= " . (TIMENOW - ($daysprune * 86400));
$show['noposts'] = false;
}
else
{
$datecut = '';
$show['noposts'] = true;
}

I have:

if (!$daysprune)
{
if ($bbuserinfo['daysprune'] != 0)
{
$daysprune = $bbuserinfo['daysprune'];
}
else
{
$daysprune = iif($foruminfo['daysprune'], $foruminfo['daysprune'], 30);
}
}

and when I follow the instructions I get an error:

Parse error: parse error, unexpected T_ELSE in /home/parapla/public_html/forums/forumdisplay.php on line 514

where line 514 is
$daysprunesel = iif($daysprune == -1, 'all', $daysprune);

Forgive me but I am extremely novice about these things! What do I need to do to make this work?

Jolten
04-27-2005, 11:04 PM
Forgive me but I am extremely novice about these things! What do I need to do to make this work?


You may want to update to 3.0.7 first.

HeloHi
04-27-2005, 11:29 PM
You may want to update to 3.0.7 first.


I have updated, I thought. Is that code from the older version or something?

See: www.forums.paraplanet.com it is 3.07


Edit: Hehe I hadn't updated my profile, sorry about that! Any thoughts on what I can do?

JMPZ
04-30-2005, 07:19 PM
I have updated, I thought. Is that code from the older version or something?

See: www.forums.paraplanet.com it is 3.07


Edit: Hehe I hadn't updated my profile, sorry about that! Any thoughts on what I can do?

EDIT: As mentioned below, he needed to look further down in the code to find the right piece.

Lynne
04-30-2005, 07:40 PM
I have updated, I thought. Is that code from the older version or something?

See: www.forums.paraplanet.com it is 3.07


Edit: Hehe I hadn't updated my profile, sorry about that! Any thoughts on what I can do?
You are at the wrong part of the code. Keep looking in the php file and you will find that code JMPZ is talking about.

Lynne
04-30-2005, 08:02 PM
Where is "$noiconurl" defined? I'm just wondering because mine won't 'unfilter' and since I don't see that defined, I'm thinking that may be the culprit.

HeloHi
04-30-2005, 08:37 PM
You are at the wrong part of the code. Keep looking in the php file and you will find that code JMPZ is talking about.

That is exactly it! Thanks so much! I am trying to get better :surprised:

edit: it works perfectly now :)

JMPZ
05-03-2005, 04:55 PM
Where is "$noiconurl" defined? I'm just wondering because mine won't 'unfilter' and since I don't see that defined, I'm thinking that may be the culprit.

My good sir, you have found a bug, and a BIG one at that. It's missing. Here's the missing part. I'll add it to the first post obviously.

In forumdisplay.php, find:

$sorturl = "forumdisplay.php?$session[sessionurl]f=$forumid&amp;daysprune=$daysprune";


And add immediately after it:

//Post icon filter hack
if ($pqr) {
$noiconurl = $sorturl;
$sorturl .= "&amp;picon=$picon";
}
//*post icon filter hack


Thanks for pointing it out. Sorry I missed that part.

Lord Brar
05-05-2005, 12:22 PM
Woah! I've been looking for something like this.... can't wait for you to make it stable :)

Fry
08-19-2005, 08:10 PM
Will this work with 3.5?

hobbes747
08-22-2005, 02:21 AM
I got it to work on RC2, but I had to change the variables a wee bit.

Beware, I'm a vBulletin novice, so I don't know if this compromises security or anything. If someone could verify that it's okay, that would be awesome.

The very first step, look for this instead
$perpage = $vbulletin->input->clean_gpc('r', 'perpage', TYPE_UINT);
$pagenumber = $vbulletin->input->clean_gpc('r', 'pagenumber', TYPE_UINT);
$daysprune = $vbulletin->input->clean_gpc('r', 'daysprune', TYPE_INT);
$sortfield = $vbulletin->input->clean_gpc('r', 'sortfield', TYPE_STR);

Immediately after, add this
$picon = $vbulletin->input->clean_gpc('r', 'picon', TYPE_INT);

The second step is okay, but you have to be sure you are at the right $daysprune or it just won't work.

The third step, look for this instead
$pagenav = construct_page_nav($pagenumber, $perpage, $totalthreads, 'forumdisplay.php?' . $vbulletin->session->vars['sessionurl'] . "f=$forumid", ""
. (!empty($vbulletin->GPC['perpage']) ? "&amp;pp=$perpage" : "")
. (!empty($vbulletin->GPC['sortfield']) ? "&amp;sort=$sortfield" : "")
. (!empty($vbulletin->GPC['sortorder']) ? "&amp;order=" . $vbulletin->GPC['sortorder'] : "")
. (!empty($vbulletin->GPC['daysprune']) ? "&amp;daysprune=$daysprune" : "")

Immediately after, add this
. (!empty($vbulletin->GPC['picon']) ? "&amp;picon=$picon" : "")

Everything else was the same I think. :nervous:

thenetbox
09-18-2005, 10:14 PM
thank you!! Installed

thenetbox
09-18-2005, 10:26 PM
Also... do you know if choosing a category/thread/post icon can be made mandatory?

thenetbox
10-04-2005, 04:16 PM
Also.. how do you remove "No Icon" from the list?

Wasim
10-20-2005, 08:46 AM
Is there any plan to make a Vb 3.5 version of this hack?

I'd really like one.

Wired1
10-21-2005, 10:54 PM
Ok, 3.5.0 version is up:

https://vborg.vbsupport.ru/showthread.php?t=98978

AGAIN, THIS IS UNTESTED SO FAR. Shouldn't crash or anything though, too simple.