June 2010

[Drupal] Howto change views2 sorting parameters programmatically.

Stub article, to be finished.
  1. function yourmodule_views_pre_view(&$view, &$display_id, &$args) {
  2. if ($view->name == 'your_views') {
  3. /* Get the Sort object */
  4. $sort = $view->display['default']->display_options['sorts'];
  5.  
  6. /* Change the sort order */
  7. $sort['name']['order'] = 'DESC';
  8.  
  9. /* Set the new sorting object */
  10. $view->display_handler->set_option('sorts', $sort);
  11. }
  12. }