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.092 seconds

For starters it's just so easy to design an app in a way that I'm used to i.e. database first then views followed by customization. The fork system is pure brilliance from a developer standpoint as I can override things and still add and update my projects with minimal effort! Truly amazing to be able to build components in Joomla using incremental refinement without having to do everything by hand. Thanks for the great tool! I am so much more productive now than ever and I can't imagine building components any other way!!!!
Dave (Forum)

Get Started