In Views 1, I had some code in the arguments section to basically modify the filter. I've searched in the issues cue for Views 2 and there appears to be a couple of different routes to do this, but I was wondering what the "correct" way to do this would be.
I'm basically creating views to display stuff by location.province. For certain provinces, I modified the filter to search for a string of multiple provinces:
<?php
$view->filter[] = array(
'vid' => $view->vid,
'field' => 'location.province',
'value' => $thefilter,
'operator' => 'word',
'position' => count($view->filter),
'id' => 'location.province');
$view->is_cacheable = 0;
?>
How should I do this in Views 2? I can use hook_views_query_alter and then inject a custom query, but is there an easier way to modify the arguments "where" section of the query? Change the argument from
<?php
location.province = %s"
?>
TO
<?php
UPPER('location.province') like UPPER(%s) OR UPPER('location.province') like UPPER(%s) ... etc
?>
Comments
Comment #1
dawehnerIf you really want to do it clean, you would implement hook_views_data_alter and alter the filter handler of the location module. Then in this filter handler provide what you need.
For me this is the easier way :)
Comment #2
esmerel commentedSolution suggested, no response.