I can't seam to get right a view query alter.
I'm passing an argument to the view but I don't need an "=" condition. I need a LIKE condition.
From the GUI I can't seem to be able to do it so I was thinking about altering the query from code.
What is the best way to alter the conditions in a code like this ?
function mymodule_query_views_alter(QueryAlterableInterface $query) {
$where =& $query->conditions();
}
Comments
Comment #1
dawehnerMaybe hook_views_query_alter is much easier to use for you.
That's a core hook, so you could ask in the forums for help.
Comment #2
paoloteo commentedhello, I can actually hook in with hook_views_query_alter but what should set to have that condition work with a "LIKE" ?
Comment #3
paoloteo commentedI've tried with something like:
but does not seam to work.
Any help is appreciated.
Comment #5
Aritra Banerjee commentedYou should work with $query->add_where() condition under _views_query_alter hook function. You can try something like this below(It worked successfully in Drupal 7):
NOTE: 1. Here "field_data_field_user_interest" field must be added in Relationship of Views configuration.
2. Any desired SQL condition can be added in add_where() of $query.