A question about the order of pagination
Currently I'm deal with a history message page using Cakephp.And I got a problem about records' order.In the contr开发者_开发问答oller,codes about pagination as follows
$this->paginate['Msg'] = array('order'=>'Msg.created desc');
$msgs = $this->paginate('Msg');
$this->set('historymsgs',$msgs);
Then I got the first page which contains the latest messges like this:
tom:I'm eighteen.
Jerry:How old are you?
tom:Tom.
Jerry:what's your name?
tom:Hi nice to meet you too!
Jerry:Hello,nice to meet you!
But what I need is the reversed order of the messages.How can I append a condition of Msg.created asc
here?
Thanks in advance.
So, in short, you want the first page to show the most recent history but, on each page, you want the messages to show in chronological order instead of reverse-chronological.
If so, you could try to use Set::sort() on the data set from each page.
精彩评论