I’d like to feed CakePHP’s paginate() function with an array I’ve built myself, like this:
class SomeController extends AppController {
var $paginate = array(
'limit' => 25,
'order' => array(
'Post.title' => 'asc'
)
);
public function index(){
$theArray = array(
array(
'Entity1'=>
array('id'=>1, 'someField'=>'value1'),
'SecondEntity'=>
array('id'=>1, 'fieldTwo'=>'reallyInteresting')
),
array(
'Entity1'=>
array('id'=>2, 'someField'=>'value2'),
'SecondEntity'=>
array('id'=>2, 'fieldTwo'=>'displayedValue')
)
);
$this->set('data',$this->paginate($theArray));
}
}
How do I do it the easiest way?
you have identical names of variable $paginate and function $this->paginate() – you need to rename one.
it’s not clear about your ordering field Post.title – there is no such field/table in the data sample.
little code sample for you: