paginated comments not showing up in view
I am fetching comments related to a post in the view function in the
posts_controller :
$this->paginate = array(
'Comment' => array(
'limit' => 2,
'page' => 1,
'order' => array('Comment.created' => 'desc'),
'conditions' => array('Comment.post_id' => $id)
)
);
$this->set('comments', $this->paginate('Comment'));
In the view.ctp file I am referencing the comments variable correctly:
foreach ($comments as $comment):
...
There is a query for this pagination in the debug info. at the bottom
of the screen, but no comments are being shown by the view. If I copy
and paste the query into phpmyadmin then there it correctly returns
one row. What is happening to the comments in the posts view?
Note I am using containable on the post model, I need this to prevent
extra queries on another form:
var $actsAs = array('Containable');
var $recursive = -1;
... and I get the post record in the posts view with:
$this->set(
'post',
$this->Post->find(
'first',
array(
'conditions' => array('Post.id' => $id),
'contain' => array(
'User' => array(
'id',
'username'
)
)
)
)
);
--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home