Guest User

Untitled

a guest
Nov 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. SELECT node_field_data.nid AS nid
  2. FROM
  3. {node_field_data} node_field_data
  4. WHERE (node_field_data.status = '1') AND (node_field_data.type IN ('article', 'recipe')) AND ((CONCAT_WS(' ', node_field_data.title) LIKE '%tartar%'))
  5. LIMIT 11 OFFSET 0
  6.  
  7. function somemodule_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
  8. if ($view->id() === 'someview' && $view->getDisplay()->display['id'] === 'somedisplay') {
  9. // Traverse through the 'where' part of the query.
  10. foreach ($query->where as &$condition_group) {
  11. foreach ($condition_group['conditions'] as &$condition) {
  12. // Find the condition to alter.
  13. if ($condition['field'] === 'node_field_data.title') {
  14. // Trimming spaces and percent symbols before adding them.
  15. $condition['value'] = trim($condition['value'], " %tnrx0B");
  16. $condition['value'] = '% ' . $condition['value'] . ' %';
  17. }
  18. }
  19. }
  20. }
  21. }
Add Comment
Please, Sign In to add comment