Return to Snippet

Revision: 47448
at June 8, 2011 08:05 by joshstrange


Initial Code
function expose_order_by_views_query_alter(&$view, &$query) 
{	
	if( isset( $_GET['sortoptions'] ) )
	{	
		$_SESSION['sortoptions'] = $_GET['sortoptions'];
	}
	if ( $_SESSION['sortoptions'] == 'A-Z' )	
		$query->orderby[0] = 'node_title ASC';	
	else if ( $_SESSION['sortoptions'] == 'Z-A' )	
		$query->orderby[0] = 'node_title DESC';
	else //No Session Data
	{
		$_SESSION['sortoptions'] = 'A-Z';
		$query->orderby[0] = 'node_title ASC';
	}
}

Initial URL


Initial Description


Initial Title
Extending Views 2 to expose sorting options

Initial Tags
drupal

Initial Language
PHP