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

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started