Seems there's yet another way to do it (would have been nice if I'd
found it about 6 hours ago, but meh... what can ya do? XD ), if you
fancy setting the default sort order for the entire controller rather
than doing each function on its own.
You can set:
var $paginate = array('order'=>array('field_name' => 'desc'));
at the beginning of your controller, and get the same effect.
On Jun 25, 4:54 pm, "Jonathan Langevin" <[EMAIL PROTECTED]> wrote:
> BTW, as I mentioned, you can pass the parameters via url as well (i've been
> playing with it now, hehe)
>
> i.e. -
> /cake/app/content/contentList/?limit=5&page=4&sort=parent_id&direction=desc
>
> etc
>
> i believe limit can also be replaced by "show"
>
> On 6/25/07, kionae <[EMAIL PROTECTED]> wrote:
>
>
>
> > I knew it had to be something ridiculously easy. :) Both ways seem
> > to work. Thanks!
>
> > On Jun 25, 2:36 pm, "Jonathan Langevin" <[EMAIL PROTECTED]> wrote:
> > > Apparently another way is to do:
> > > $this->params['order'] = array();
> > > $this->params['order']['id'] = 'desc';
>
> > > On 6/25/07, Jonathan Langevin <[EMAIL PROTECTED]> wrote:
>
> > > > Where are you calling paginate from? in your controller?
> > > > if so, just try
> > > > $this->params['sort'] = 'id';
> > > > $this->params['direction'] = 'desc';
>
> > > > before you call $this->paginate();
>
> > > > On 6/25/07, kionae <[EMAIL PROTECTED]> wrote:
>
> > > > > The problem with that is that I can't figure out how/where to set
> > > > > them. They don't seem to come from the parameters passed through
> > the
> > > > > paginate function in the controller, but rather from the $options
> > > > > array and I don't know how to set things in the $options array.
>
> > > > > On Jun 25, 1:56 pm, "Jonathan Langevin" <[EMAIL PROTECTED]> wrote:
> > > > > > According to cake/libs/controller/controller.php (function
> > paginate),
> > > > > it
> > > > > > appears you need to set "sort" and "direction":
> > > > > > sort => true
> > > > > > direction => 'asc'|'desc'
>
> > > > > > it will check $this->params, $this->params['url'], and
> > > > > $this->passedArgs, so
> > > > > > try it in your url, might be the easiest test for now
>
> > > > > > On 6/25/07, kionae <[EMAIL PROTECTED]> wrote:
>
> > > > > > > The problem is not getting paginate in 1.2 to work, but rather
> > > > > > > changing the default sort order. Everything is sorted in
> > ascending
> > > > > > > order on the ID field when the page initially loads, but I need
> > it
> > > > > in
> > > > > > > descending order on the date field... and for the life of me, I
> > > > > can't
> > > > > > > find any way to specify this when calling $this->paginate() in
> > the
> > > > > > > controller. The API has been less than helpful, as all it has
> > to
> > > > > say
> > > > > > > about paginate is:
>
> > > > > > > Controller::paginate ( $object = null,
> > > > > > > $scope = array(),
> > > > > > > $whitelist = array() )
>
> > > > > > > Handles automatic pagination of model records
> > > > > > > Parameters:
> > > > > > > mixed $object
> > > > > > > mixed $scope
> > > > > > > array $whitelist
>
> > > > > > > There has to be some way to tell it to spit things out in
> > descending
> > > > > > > order on whichever field I specify, instead of the default
> > ascending
>
> > > > > > > order on the ID field... I know I'm probably missing something
> > > > > > > stupidly easy, but I can't figure it out. Help?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---