Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. if node property = x
  2. use this sort criteria
  3. else
  4. use this one
  5.  
  6. /**
  7. * Implements hook_views_query_alter().
  8. */
  9. function HOOK_views_query_alter(&$view, &$query) {
  10. if ($view->name == 'view_name' && $view->current_display == 'page') {
  11. $query->orderby = array(
  12. array(
  13. 'field' => 'CASE WHEN node.property = x THEN node.y ELSE node.z END',
  14. 'direction' => 'ASC',
  15. )
  16. );
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement