MyBB Hacks

Full Version: Filter Threads By Thread Prefix - MyBB 1.6 Only
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
Now, we can filter threads by the default MyBB thread prefix using XThreads.

Then, we need to edit our forumdisplay_thread template:
Find:

Code:
{$thread['threadprefix']}


Replace with:

HTML Code
<a href="{$forumurl_q}filterxt_prefix={$thread['prefix']}">{$thread['threadprefix']}</a>


With the modification above, we can filter threads by thread prefix (click the thread prefix).


Additional Info:

The filter format should be like this:

Code:
filterxt_prefix=prefix_id


Example:
We want to display threads which has thread prefix id = 2 only. So, the filter format should be like this:

Code:
filterxt_prefix=2


And, we can use an array for this too. The format should be like this:

Code:
filterxt_prefix[]=prefix_id_a&filterxt_prefix[]=prefix_id_b&filterxt_prefix[]=prefix_id_c


Example:
We want to display threads which has thread prefix id = 1, threads which has thread prefix id = 2 and threads which has thread prefix id = 3. The filter format should be like this:

Code:
filterxt_prefix[]=1&filterxt_prefix[]=2&filterxt_prefix[]=3


With this concept, as an optional, we can place the thread prefix filter in our forumdisplay_threadlist template manually.
Example:

HTML Code
<a href="{$forumurl_q}filterxt_prefix[]=1&amp;filterxt_prefix[]=2&amp;filterxt_prefix[]=3">Display Prefix 1, Prefix 2 and Prefix 3</a>

Yay, thanks RateU - I was feeling a bit lost looking at that prefix thing so this is a big help.
Thanks RateU Biggrin
Instead of editing the template, I edited the prefix itself. more specifically, the "Display Style" area of the prefix. I simply placed the filter link before the prefix display.
Example:

Code:
<a href="./forumdisplay.php?fid=37&filterxt_prefix=7"><strong>[prefix text]</strong></a>


both ways will work.

Thanks RateU Smile

@x-Treme: probably the main issue with that is that it forces the prefix to a single forum, but if that's all you need, then it works fine as well Tongue
Never thought of that. But that is all I need it for, so I'll leave it as is for now.
Great feature though.
Thank You very much RateU Smile
Filtering Thread By Thread Icon:

Filtering threads by thread icon (works in both version - MyBB 1.4 and MyBB 1.6), should be similar with filtering thread by thread prefix. Change prefix to icon.

Then, we need to edit our forumdisplay_thread template:
Find:

Code:
{$icon}


Replace with:

HTML Code
<a href="{$forumurl_q}filterxt_icon={$thread['icon']}">{$icon}</a>


If we want to put the thread icon filter manually in forumdisplay_threadlist template, we can use URL like this:

HTML Code
<a href="{$forumurl_q}filterxt_icon=icon_id"><img src="{$icon_cache['icon_id']['path']}" alt="{$icon_cache['icon_id']['name']}" title="{$icon_cache['icon_id']['name']}" /></a>

Replace icon_id with Icon ID.

We can use an array for this too.

Additional Info:

This is an example URL for displaying all threads with prefix_id=1 and post_icon_id=2:

HTML Code
<a href="{$forumurl_q}filterxt_prefix=1&amp;filterxt_icon=2">Whatever</a>

Hi RateU, I am working on a forum set up and I wanted to use this trick on the similar threads - This is the content of my res_showthread_similarthreads_bit

Code:
<tr>
	<td align="center" class="{$trow}" width="2%">{$icon}</td>
	<td class="{$trow}">{$similar_thread['threadprefix']}<a href="{$similar_thread['threadlink']}">{$similar_thread['subject']}</a></td>
	
	</tr>


But when I try and put the XThreads filter fix in as so

Code:
<a href="{$forumurl_q}filterxt_prefix={$thread['prefix']}">{$thread['threadprefix']}</a>


it does not work - but - if you do it like as below, it does

Code:
<tr>
	<td align="center" class="{$trow}" width="2%">{$icon}</td>
	<td class="{$trow}"><a href="{$forumurl_q}filterxt_prefix={$thread['prefix']}">{$similar_thread['threadprefix']}</a><a href="{$similar_thread['threadlink']}">{$similar_thread['subject']}</a></td>
	
	</tr>


Just my addition Smile

For the showthread_similarthreads_bit template, maybe you mean like this, Lee?

HTML Code
<a href="{$forumurl_q}filterxt_prefix={$similar_thread['prefix']}">{$similar_thread['threadprefix']}</a>

Pages: 1 2 3 4 5 6
Reference URL's