Hi,

As per the code at http://api13.cakephp.org/view_source/controller/#l-1060and
http://api13.cakephp.org/view_source/controller/#l-1128 , I don't think
paginate() can sort using the field of model which has more than one level
deep relation with the paginated model.

Amit Badkas

PHP Applications for E-Biz: http://www.sanisoft.com



On Mon, Jan 31, 2011 at 3:42 AM, Pete <peterbald...@gmail.com> wrote:

> Dear all,
>
> I suspect this is either really easy or very hard. I've been through
> endless apparently similar questions on here but haven't been able to
> figure out the answer.
>
> I have a "Quote" model, which I am trying to list in a view. Quote
> belongsTo Attendance which belongs to Person. I am trying to sort the
> list of quotes by the first_name field in the Person model.
>
> The array being sent to the view is
>
> Array
> (
>     [0] => Array
>            (
>                [Quote] => Array
>                     (
>                        [id] => 1
>                        [attendance_id] => 15
>                        [quote_text] => Hello
>
>            )
>
>                [Attendance] => Array
>            (
>                        [id] => 15
>                        [person_id] => 2
>                        [trip_id] => 7
>                        [Person] => Array
>                             (
>                              [id] => 2
>                              [first_name] => John
>                              [last_name] => Smith
>
>                               )
>
>                        )
>        )
>
>
> }
> This seems to work fine, and in the view, I can echo out
>
>    foreach ($quotes as $quote) {
>    echo $quote['Attendance']['Person']['first_name'];
> }
> without any problem.
>
> What I cannot get to work is accessing/using the same variable as a
> sort field in paginate
>
>   echo $this->Paginator->sort('Name',
> 'Attendance.Person.first_name');
> or
>
>    echo $this->Paginator->sort('Location',
> 'Attendance.Trip.location');
>
> Does not work. It appears to sort by something, but I'm not sure what.
> Am I using the correct syntax?. Is there something I should be doing
> in a model or controller to make this work?
>
> Thanks in advance.
>
> Peter
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>For
>  more options, visit this group at
> http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to