Skip to content

Instantly share code, notes, and snippets.

@szeidler
Created February 16, 2017 18:48
Show Gist options
  • Save szeidler/f2cd3432607f5b23971334f20e7827ed to your computer and use it in GitHub Desktop.
Save szeidler/f2cd3432607f5b23971334f20e7827ed to your computer and use it in GitHub Desktop.
<?php
/**
* Implements hook_views_query_alter().
*/
function ramsalt_shy_replacement_views_query_alter(&$view, &$query) {
if ($view->name === 'frontpage_admin') {
foreach ($query->where[1]['conditions'] as $delta => $condition) {
if ($condition['field'] === 'node.title') {
$query->add_where_expression(1, "REPLACE(node.title, '=', '') " . $condition['operator'] . " '" . $condition['value'] . "'");
unset($query->where[1]['conditions'][$delta]);
}
}
}
}
@szeidler
Copy link
Author

Side-effect. It's a simple REPLACE(), not the more complex pattern we're using in PHP: /([a-z]+)=([a-z]+)/i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment