Forums

[HOWTO] Backend Ordering

customhost 25 Mar, 2010
Hi erverybody,

I don't know whether anybody else except for me ever wanted the specified "Order fields" to also apply to the backend view of ChronoConnectivity but if so, you will probably notice the same problem: the specified fields are simply ignored and backend ordering is always performed by the primary id of the database connection table.

So if you want to make use of the order fields not only in the frontend, but also in the backend edit view, simply make the following changes to the file "admin.chronoconnectivity.php" (as of version 2 RC3):

Find the following lines of code (around line 367):

$pageNav = new JPagination($total, $limitstart, $limit); 
$filter_order		= $mainframe->getUserStateFromRequest( $option.$connections[0]->name.'filter_order', 		$connections[0]->name.'_filter_order', 	$row->getKeyName(),	'cmd' );
$filter_order_Dir	= $mainframe->getUserStateFromRequest( $option.$connections[0]->name.'filter_order_Dir',	$connections[0]->name.'_filter_order_Dir',	'',		'word' );
# main database query
$database->setQuery( "SELECT * FROM ".$connections[0]->tablenames." ORDER BY `".($filter_order ? $filter_order : $row->getKeyName()).'` '. $filter_order_Dir." LIMIT $pageNav->limitstart,$pageNav->limit" );


Replace them as follows:

$pageNav = new JPagination($total, $limitstart, $limit); 
$params = new JParameter($connections[0]->paramsall);
$filter_order		= $mainframe->getUserStateFromRequest( $option.$connections[0]->name.'filter_order', 		$connections[0]->name.'_filter_order', 	trim($params->get('ordersql')),	'cmd' );
$filter_order_Dir	= $mainframe->getUserStateFromRequest( $option.$connections[0]->name.'filter_order_Dir',	$connections[0]->name.'_filter_order_Dir',	'',		'word' );
# main database query
$database->setQuery( "SELECT * FROM ".$connections[0]->tablenames." ORDER BY ".($filter_order ? $filter_order : $row->getKeyName()).' '. $filter_order_Dir." LIMIT $pageNav->limitstart,$pageNav->limit" );


That should do the trick.

I hope this snippet is useful for anybody :wink:

Regards,
Eric
This topic is locked and no more replies can be posted.