Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Order By 29 Feb 2012 02:54 #1480

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);
}

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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

Please Log in or Create an account to join the conversation.

Last edit: by admin.

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

I cant find ths in my controller

$app->setUserState

How can I do that in my view?

thanks for your replay

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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

Please Log in or Create an account to join the conversation.

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

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?

Please Log in or Create an account to join the conversation.

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

Any news?

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.093 seconds

Although I found this tool some time ago I just started learning experimenting and building this first component on Monday and now on Thursday afternoon it's already online. Although I already had a working version done with another tool this is much easier to build and at the end you have the freedom to own your own component. Once you know how to use Cook you will boost your productivity as the learning curve is really moderate compared to many other tools.
Giori (Forum)

Get Started