I have an Author who is has a Book and where the "book" was written (
book_id.name, city_id.name)
Author sort works, title sort work, but not the sort for city_id. I can
sort by the id, but obviously this won't work because
the id has nothing to do with the name of the city.
<th><?php echo $this->Paginator->sort('Author', 'name'); ?></th>
<th><?php echo $this->Paginator->sort('Book', 'title.name'); ?></th>
<th><?php echo $this->Paginator->sort('Where Written',
'title.city_id'); ?></th>
(sorts, but the names are not sorted because
it is using the id)
need something like this
<th><?php echo $this->Paginator->sort('Where Written', 'title.city_id.name');
?></th> //does not work.
Is there a way to get this to work, or is it a customer pagination?
> I have an Author who is has a Book and where the "book" was written ( > book_id.name, city_id.name) > Author sort works, title sort work, but not the sort for city_id. I can > sort by the id, but obviously this won't work because > the id has nothing to do with the name of the city.
> <th><?php echo $this->Paginator->sort('Author', 'name'); ?></th> > <th><?php echo $this->Paginator->sort('Book', 'title.name'); ?></th> > <th><?php echo $this->Paginator->sort('Where Written', 'title.city_id'); > ?></th> (sorts, but the names are not sorted because > it is using the id)
> need something like this > <th><?php echo $this->Paginator->sort('Where Written', 'title.city_id.name > '); ?></th> //does not work.
> Is there a way to get this to work, or is it a customer pagination?
> what version are you using?
> because in 2.x it should be the other way around:
> sort($key, $title)
> please always mention your cake version
> Am Donnerstag, 26. April 2012 01:29:26 UTC+2 schrieb Hill180:
>> Trying to use the paginator in the view
>> I have an Author who is has a Book and where the "book" was written (
>> book_id.name, city_id.name)
>> Author sort works, title sort work, but not the sort for city_id. I can
>> sort by the id, but obviously this won't work because
>> the id has nothing to do with the name of the city.
>> <th><?php echo $this->Paginator->sort('**Author', 'name'); ?></th>
>> <th><?php echo $this->Paginator->sort('Book', 'title.name'); ?></th>
>> <th><?php echo $this->Paginator->sort('Where Written', 'title.city_id');
>> ?></th> (sorts, but the names are not sorted because
>> it is using the id)
>> need something like this
>> <th><?php echo $this->Paginator->sort('Where Written', '
>> title.city_id.name'); ?></th> //does not work.
>> Is there a way to get this to work, or is it a customer pagination?
>> thanks..
>> j
> --
> 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+unsubscribe@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
On Wednesday, April 25, 2012 4:29:26 PM UTC-7, Hill180 wrote:
> Trying to use the paginator in the view
> I have an Author who is has a Book and where the "book" was written ( > book_id.name, city_id.name) > Author sort works, title sort work, but not the sort for city_id. I can > sort by the id, but obviously this won't work because > the id has nothing to do with the name of the city.
> <th><?php echo $this->Paginator->sort('Author', 'name'); ?></th> > <th><?php echo $this->Paginator->sort('Book', 'title.name'); ?></th> > <th><?php echo $this->Paginator->sort('Where Written', 'title.city_id'); > ?></th> (sorts, but the names are not sorted because > it is using the id)
> need something like this > <th><?php echo $this->Paginator->sort('Where Written', 'title.city_id.name > '); ?></th> //does not work.
> Is there a way to get this to work, or is it a customer pagination?
On Thu, Apr 26, 2012 at 7:46 AM, jeremyharris <funeralm...@gmail.com> wrote:
> Is City a hasOne or belongsTo relationship? If so, and your find code is
> using contain or recursive to include those in the results, you can do this:
> Check your data and SQL queries to see if it's joined that way.
> On Wednesday, April 25, 2012 4:29:26 PM UTC-7, Hill180 wrote:
>> Trying to use the paginator in the view
>> I have an Author who is has a Book and where the "book" was written (
>> book_id.name, city_id.name)
>> Author sort works, title sort work, but not the sort for city_id. I can
>> sort by the id, but obviously this won't work because
>> the id has nothing to do with the name of the city.
>> <th><?php echo $this->Paginator->sort('**Author', 'name'); ?></th>
>> <th><?php echo $this->Paginator->sort('Book', 'title.name'); ?></th>
>> <th><?php echo $this->Paginator->sort('Where Written', 'title.city_id');
>> ?></th> (sorts, but the names are not sorted because
>> it is using the id)
>> need something like this
>> <th><?php echo $this->Paginator->sort('Where Written', '
>> title.city_id.name'); ?></th> //does not work.
>> Is there a way to get this to work, or is it a customer pagination?
>> thanks..
>> j
> --
> 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+unsubscribe@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
class Book extends AppModel { var $belongsTo = array('City', 'Author');
}
Then you can paginate like the example I had above since it will LEFT join the city models for all the books, as long as you contain the city model:
// in books controller $this->paginate = array( 'contain' => array('City', 'Author'); ); $this->paginate('Book'); // paginate from the book model to be able to sort by Book, Author or City
> On Thu, Apr 26, 2012 at 7:46 AM, jeremyharris <funeralm...@gmail.com>wrote:
>> Is City a hasOne or belongsTo relationship? If so, and your find code is >> using contain or recursive to include those in the results, you can do this:
>> Check your data and SQL queries to see if it's joined that way.
>> On Wednesday, April 25, 2012 4:29:26 PM UTC-7, Hill180 wrote:
>>> Trying to use the paginator in the view
>>> I have an Author who is has a Book and where the "book" was written ( >>> book_id.name, city_id.name) >>> Author sort works, title sort work, but not the sort for city_id. I can >>> sort by the id, but obviously this won't work because >>> the id has nothing to do with the name of the city.
>>> <th><?php echo $this->Paginator->sort('**Author', 'name'); ?></th> >>> <th><?php echo $this->Paginator->sort('Book', 'title.name'); ?></th> >>> <th><?php echo $this->Paginator->sort('Where Written', 'title.city_id'); >>> ?></th> (sorts, but the names are not sorted because >>> it is using the id)
>>> need something like this >>> <th><?php echo $this->Paginator->sort('Where Written', ' >>> title.city_id.name'); ?></th> //does not work.
>>> Is there a way to get this to work, or is it a customer pagination?
>>> thanks.. >>> j
>> -- >> 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+unsubscribe@googlegroups.com For more options, visit this group >> at http://groups.google.com/group/cake-php
> class Book extends AppModel {
> var $belongsTo = array('City', 'Author');
> }
> Then you can paginate like the example I had above since it will LEFT join
> the city models for all the books, as long as you contain the city model:
> // in books controller
> $this->paginate = array(
> 'contain' => array('City', 'Author');
> );
> $this->paginate('Book'); // paginate from the book model to be able to
> sort by Book, Author or City
> On Thursday, April 26, 2012 3:06:34 PM UTC-7, Hill180 wrote:
>> City hasMany books, books only have one author.
>> On Thu, Apr 26, 2012 at 7:46 AM, jeremyharris <funeralm...@gmail.com>wrote:
>>> Is City a hasOne or belongsTo relationship? If so, and your find code is
>>> using contain or recursive to include those in the results, you can do this:
>>> Check your data and SQL queries to see if it's joined that way.
>>> On Wednesday, April 25, 2012 4:29:26 PM UTC-7, Hill180 wrote:
>>>> Trying to use the paginator in the view
>>>> I have an Author who is has a Book and where the "book" was written (
>>>> book_id.name, city_id.name)
>>>> Author sort works, title sort work, but not the sort for city_id. I can
>>>> sort by the id, but obviously this won't work because
>>>> the id has nothing to do with the name of the city.
>>>> <th><?php echo $this->Paginator->sort('**Author**', 'name'); ?></th>
>>>> <th><?php echo $this->Paginator->sort('Book', 'title.name'); ?></th>
>>>> <th><?php echo $this->Paginator->sort('Where Written', 'title.city_id');
>>>> ?></th> (sorts, but the names are not sorted because
>>>> it is using the id)
>>>> need something like this
>>>> <th><?php echo $this->Paginator->sort('Where Written', '
>>>> title.city_id.name'); ?></th> //does not work.
>>>> Is there a way to get this to work, or is it a customer pagination?
>>>> thanks..
>>>> j
>>> --
>>> 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.
>> --
> 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+unsubscribe@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>> class Book extends AppModel { >> var $belongsTo = array('City', 'Author'); >> }
>> Then you can paginate like the example I had above since it will LEFT >> join the city models for all the books, as long as you contain the city >> model:
>> // in books controller >> $this->paginate = array( >> 'contain' => array('City', 'Author'); >> ); >> $this->paginate('Book'); // paginate from the book model to be able to >> sort by Book, Author or City
>> On Thursday, April 26, 2012 3:06:34 PM UTC-7, Hill180 wrote:
>>> City hasMany books, books only have one author.
>>> On Thu, Apr 26, 2012 at 7:46 AM, jeremyharris <funeralm...@gmail.com>wrote:
>>>> Is City a hasOne or belongsTo relationship? If so, and your find code >>>> is using contain or recursive to include those in the results, you can do >>>> this:
>>>> Check your data and SQL queries to see if it's joined that way.
>>>> On Wednesday, April 25, 2012 4:29:26 PM UTC-7, Hill180 wrote:
>>>>> Trying to use the paginator in the view
>>>>> I have an Author who is has a Book and where the "book" was written ( >>>>> book_id.name, city_id.name) >>>>> Author sort works, title sort work, but not the sort for city_id. I >>>>> can sort by the id, but obviously this won't work because >>>>> the id has nothing to do with the name of the city.
>>>>> <th><?php echo $this->Paginator->sort('**Author**', 'name'); ?></th> >>>>> <th><?php echo $this->Paginator->sort('Book', 'title.name'); ?></th> >>>>> <th><?php echo $this->Paginator->sort('Where Written', >>>>> 'title.city_id'); ?></th> (sorts, but the names are not sorted because >>>>> it is using the id)
>>>>> need something like this >>>>> <th><?php echo $this->Paginator->sort('Where Written', ' >>>>> title.city_id.name'); ?></th> //does not work.
>>>>> Is there a way to get this to work, or is it a customer pagination?
>>>>> thanks.. >>>>> j
>>>> -- >>>> 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.
>>> -- >> 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+unsubscribe@googlegroups.com For more options, visit this group >> at http://groups.google.com/group/cake-php
Why didn't you use the $belongsTo array I gave you? Your belongsTo has changed the aliases from MainCity to main_city, so paginating by MainCity will not work.
Rename the aliases to be CamelCased and try again. Also, debug the results of $this->paginate() to make sure it includes the MainCity and any other data you are trying to sort by.