It seems like this should be done without resorting to using custom pagination.
In your models, you must establish the following relationships:
hasMany ( hasOne) CarImage
CarImage
, :
<?php
class CarsController extends AppController {
var $paginate = array('limit'=>'10',
'order'=>'Car.created',
'fields'=>array('Car.model','Car.year','Car.description',
'CarImage.thumbnail'));
function test() {
$category = "somevalue";
$conditions = array('Car.make LIKE' => '%'.$category.'%');
$this->set('cars', $this->paginate($conditions);
}
}
?>
( paginate , ): http://book.cakephp.org/view/74/Complex-Find-Conditions