Is there any way to change the default operators so that they will behave like a taxonomy term query? I.e. the spaces do not signify new strings while a comma does. This would make it easier for the users to use the query instead of informing them they need to use quotation marks to signify an entire string.

Comments

roychri’s picture

As far as I know, that is not currently possible. I think some serious changes would need to be done in the code to allow that.

What you can do it create a peice of PHP code that you can put in your views "Argument Handling Code" which would modify the array $filters to replace what the user entered (commas, no quotations) by what the TQL exposed filter expects (spaces and quotes). That way your users will be able to use coma but the system would translate that automagically.

Maybe something like this:

$filters[0]['filter'] = preg_replace('/(^|,)([^,]+\s+[^,]+)(,|$)/', '\1"\2"\3', $filters[0]['filter']);
$filters[0]['filter'] = str_replace(',', ' ', $filters[0]['filter']);

I have not tested this code, this is just to show you how it might be done. You will have to craft your own code.

Kripsy’s picture

I was passing the argument through the url so I used this argument handling code

$args[0] = str_replace('"', '', $args[0]);

$view->argument[0]['title'] = $args[0].' Images';

$args[0] = preg_replace('/(^|,)([^,]+\s+[^,]+)(,|$)/', '\1"\2"\3', $args[0]);
$args[0] = str_replace(',', ' ', $args[0]);
return $args;

I have to add the $args[0] = str_replace('"', '', $args[0]); part because otherwise it will recursively add " " around the argument every time the view is refiltered. I still need to make adjustments for the commas, but for now it works with one tag at a time.

One question I do have though, if you have the time to help. If I try to pass an argument with a # symbol, the argument ends right before the # symbol. This only happens if I do a URL argument, using the actual filter works just fine. Any ideas?