Reputation: 3321
I am following the instruction in the cookbook web site of CakePHP: link text
And got this error:
Undefined variable: paginator [APP/views/post/index.ctp, line 46]
I am not sure if $paginator is a built-in variable in cakePHP 1.26.
In my Controller, I have this:
$this->set('posts', $this->Site1->find('all', array('conditions'=>array('Post.zero'=>'0'), 'order'=>array('Post.created DESC'), 'limit'=>'3')));
And in the .ctp file, I have this:
<table>
<tr><td>
<?php echo $paginator->numbers(); ?>
<?php
echo $paginator->prev('Previous', null, null);
echo $paginator->next(' Next', null, null);
?>
</td></tr>
</table>
How do I know if Site1 or Post is not the default Model in a controller?
Upvotes: 0
Views: 2087
Reputation: 6047
This is your code:
$this->paginate = array('order'=>array('Post.created DESC'), 'limit'=>3);
$this->set('posts', $this->paginate(null, array('Post.zero'=>'0')));
If the Site1 is not the default Model in that controller, then use
$this->set('posts', $this->paginate($this->Site1, array('Post.zero'=>'0')));
Try to use bake console - it's much easier instead of wild guessing :)
Upvotes: 2