Welcome, Guest
Username: Password: Remember me

TOPIC: Order By

Order By 29 Feb 2012 02:54 #1480

  • chule143
  • chule143's Avatar
  • Offline
  • New Member
  • Posts: 7
  • Karma: 0
How I can change the descending order by date, and the maximum number to 5 by default?

I'm trying the following code to the order but it ruins the pagination:

function _buildQueryOrderBy()
{
$order = array();
$pre_order = 'a.date_added DESC';

return parent::_buildQueryOrderBy($order, $pre_order);
}
The administrator has disabled public write access.

Re: Order By 08 Mar 2012 21:52 #1523

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Do it in the controller constructor :
// Register the filtering request variables
...
$app->setUserState( $this->namespace . 'filter_order',		'my_sort_field');
$app->setUserState( $this->namespace . 'filter_order_Dir',	'desc' );

You can also write it in the view, but you should create the namespace var before.
Coding is now a piece of cake
Last Edit: 08 Mar 2012 21:52 by admin.
The administrator has disabled public write access.

Re: Order By 08 Mar 2012 21:59 #1526

  • chule143
  • chule143's Avatar
  • Offline
  • New Member
  • Posts: 7
  • Karma: 0
I cant find ths in my controller

$app->setUserState

How can I do that in my view?

thanks for your replay
The administrator has disabled public write access.

Re: Order By 08 Mar 2012 22:16 #1528

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
So, put it at the end of the __construct() method.


In the view, it is not complicated, but $this->namespace is not initilizated.

Have a look in classes/jcontroller.php to understand how $this->namespace is initializated.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Order By 13 Mar 2012 19:29 #1591

  • chule143
  • chule143's Avatar
  • Offline
  • New Member
  • Posts: 7
  • Karma: 0
Works like a charm, but the pagination doesn't work :(

this is my code in the controller.php of my component:

$app->setUserState( $this->namespace . 'filter_order', 'fecha_edicion');
$app->setUserState( $this->namespace . 'filter_order_Dir', 'desc' );

Do I need to add more code?
The administrator has disabled public write access.

Re: Order By 19 Mar 2012 19:30 #1671

  • chule143
  • chule143's Avatar
  • Offline
  • New Member
  • Posts: 7
  • Karma: 0
Any news?
The administrator has disabled public write access.
Time to create page: 0.088 seconds

Get Started