Guest User

Untitled

a guest
Oct 21st, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. function MYMODULE_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
  2. if($view->id() == 'myview'){
  3. foreach ($query->where as &$condition_group) {
  4. foreach ($condition_group['conditions'] as &$condition) {
  5. if ($condition['field'] == "node_field_data.nid") {
  6. $condition = array(
  7. 'field' => "node_field_data.nid",
  8. 'value' => [2,4,6,1,3,5],
  9. 'operator' => 'in',
  10. );
  11. break;
  12. }
  13. }
  14. }
  15. //this does not work
  16. //$query->addOrderBy('node_field_data','nid', 'ASC', '', [2,4,6,1,3,5]);
  17. }
  18. }
Add Comment
Please, Sign In to add comment