I have vendors, each vendor has many reviews and many categories. I'd
like paginate to be able to sort by the AVG reviews and also
categories. For example, this displays ok, but only the vendor name is
sortable:

// in vendor controller
$this->paginate = array(
        'limit'   => 20,
        'fields' => array('Vendor.name', 'Category.name', 'AVG
(VendorReview.rating) as avg_rating'),
        'group'  => array('VendorCategory.id'),
        'joins'  => array(
            array(
                'table'=>'vendor_reviews',
                'alias'=>'VendorReview',
                'type' => 'LEFT',
 
'conditions'=>array('Vendor.id=VendorReview.vendor_id')
            ),
            array(
                'table'=>'categories',
                'alias'=>'Category',
                'type' => 'LEFT',
 
'conditions'=>array('VendorCategory.category_id=Category.id')
            )
      ),
      'conditions' =>$conditions
);

$vendors = $this->paginate('Vendor');
$this->set(compact('vendors'));



<!--in vendor view-->
...
<th><?php echo $this->Paginator->sort('avg_rating');?></th>
<th><?php echo $this->Paginator->sort('name');?></th>
<th><?php echo $this->Paginator->sort('category');?></th>
...


How do I do this?

-- 
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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to