Created
March 21, 2013 13:50
-
-
Save amitaibu/5213138 to your computer and use it in GitHub Desktop.
Make Views seach for LIKE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_views_query_alter(). | |
*/ | |
function devel_views_query_alter(&$view, &$query) { | |
if (empty($query->where[1]['conditions'][1]['field'])) { | |
return; | |
} | |
$sub_query = $query->where[1]['conditions'][1]['field']; | |
if (!$conditions = &$sub_query->conditions()) { | |
return; | |
} | |
if (!$conditions_2 = &$conditions[1]['field']->conditions()) { | |
return; | |
} | |
$conditions_2[0]['value'] = '%' . $conditions_2[0]['value'] . '%'; | |
$conditions_2[0]['operator'] = 'LIKE'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment