[Drupal] Howto change views2 sorting parameters programmatically.

Stub article, to be finished.

function yourmodule_views_pre_view(&$view, &$display_id, &$args) {
	if ($view->name == 'your_views') {
	    /* Get the Sort object */
	    $sort = $view->display['default']->display_options['sorts'];
 
	    /* Change the sort order */
	    $sort['name']['order'] = 'DESC';
 
	    /* Set the new sorting object */
	    $view->display_handler->set_option('sorts', $sort);
	}
 
}

Leave a Reply