Posted By

joshstrange on 06/08/11


Tagged

drupal


Versions (?)

Extending Views 2 to expose sorting options


 / Published in: PHP
 

  1. function expose_order_by_views_query_alter(&$view, &$query)
  2. {
  3. if( isset( $_GET['sortoptions'] ) )
  4. {
  5. $_SESSION['sortoptions'] = $_GET['sortoptions'];
  6. }
  7. if ( $_SESSION['sortoptions'] == 'A-Z' )
  8. $query->orderby[0] = 'node_title ASC';
  9. else if ( $_SESSION['sortoptions'] == 'Z-A' )
  10. $query->orderby[0] = 'node_title DESC';
  11. else //No Session Data
  12. {
  13. $_SESSION['sortoptions'] = 'A-Z';
  14. $query->orderby[0] = 'node_title ASC';
  15. }
  16. }

Report this snippet  

You need to login to post a comment.