Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT node_field_data.nid AS nid
- FROM
- {node_field_data} node_field_data
- WHERE (node_field_data.status = '1') AND (node_field_data.type IN ('article', 'recipe')) AND ((CONCAT_WS(' ', node_field_data.title) LIKE '%tartar%'))
- LIMIT 11 OFFSET 0
- function somemodule_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
- if ($view->id() === 'someview' && $view->getDisplay()->display['id'] === 'somedisplay') {
- // Traverse through the 'where' part of the query.
- foreach ($query->where as &$condition_group) {
- foreach ($condition_group['conditions'] as &$condition) {
- // Find the condition to alter.
- if ($condition['field'] === 'node_field_data.title') {
- // Trimming spaces and percent symbols before adding them.
- $condition['value'] = trim($condition['value'], " %tnr x0B");
- $condition['value'] = '% ' . $condition['value'] . ' %';
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment