MyBB Hacks

Full Version: unexpected filter behaviour?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Right now if you filter the threadlist using &filtertf_field= without a value, it hides all threads where filterf_field is unset. Not specifying a value should imply that the filter is disabled.
This may seem like a minor issue, but it complicated things a lot when using a form to allow users to set the filters of optional fields.
I have some optional filter fields too.
What I do is (as an alternative), make it a required field, and put a "global" value at the first line of the Value Lists.

For example:

Code:
Other
Games
Movie

(12-11-2011 03:49 AM)Patrick_ Wrote: [ -> ]Right now if you filter the threadlist using &filtertf_field= without a value, it hides all threads where filterf_field is unset. Not specifying a value should imply that the filter is disabled.
Actually, if it's blank, it'll show all threads where no value has been set for the thread field.
If you wish to ignore blank values, you need to make the thread field a required field.
You're.

I've created a plugin to solve this issue:

PHP Code:
$plugins->add_hook('forumdisplay_start', 'plugin_forumdisplay_start', 1);

function plugin_forumdisplay_start()
{
	global $mybb;
	if ($mybb->input['filtertf_field'] == '')
		unset($mybb->input['filtertf_field']);
}

Reference URL's