I am using cakephp 1.26 and doing pagination. could you help me with the following code please? I can't figure out what's wrong in the code.
$this->set('posts', $this->paginate = array('order'=>array('Post.created'=> 'DESC'), 'conditions'=>array('Post.zero'=>'0'), 'limit'='6'
)
);
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>
Your code is bad. You cannot make the assignment within the function call. Either do:
$this->set('posts', $this->paginate('Post',array(
'order' => array('Post.created' => 'DESC'),
'conditions' => array('Post.zero' => '0'),
'limit' => '6'
)));
or:
$this->paginate = array(
'order' => array('Post.created' => 'DESC'),
'conditions' => array('Post.zero' => '0'),
'limit' => '6');
$this->set('posts', $this->paginate('Post'));
);