Closed maddrid closed 6 years ago
@web-media ran into this today too. It appears that the Rewrite class has only been written to expect strings, not arrays. :(
My workaround was to add a function and hook call in my theme's functions file and also to give my checkboxes unique names, but all prefixed with the same identifier, for example cat1, cat2, etc. To keep things extra simple, I actually used the category's ID as the numeric part of the name.
The function looks like this:
if (!function_exists('customPrepareCategories')) {
function customPrepareCategories()
{
// grab the original GET array
$getParams = Params::getParamsAsArray('get');
// filter it down to our prefixed checkboxes
$categories = array_filter(
$getParams,
function ($key) {
// regex assumes that we will have up to a 5-digit category id,
// but really your regex should work for your checkbox name style
return preg_match('/^cat[0-9]{1,5}$/', $key) === 1;
},
ARRAY_FILTER_USE_KEY
);
// join all the category ids with a comma
$sCategory = implode(',', $categories);
// reset the sCategory param
Params::setParam('sCategory', $categories);
}
}
osc_add_hook('before_search', 'customPrepareCategories');
same issue #2259
works fine but throws warning message when hitting apply on search sidebar
also
from bender theme (sCategory not passed to params )
this works