On Nov 13, 5:27 pm, phpMagpie <[email protected]> wrote:
> ...
> In essence you need a separate find for your category:
> $this->set('category', $this->Category->find('first', array(
> 'conditions' => array('Category.id' => $id),
> 'contain' => array(
> 'Post' => array('User' => array('id', 'username') )
> )
> )));
I got rid of this as there were too many unnecessary queries going on.
>
> And a separate paginate for the post records you want to paginate:
> $this->paginate = array(
> 'Post' => array(
> 'limit' => 2,
> 'page' => 1,
> 'order' => array('Post.created' => 'desc'),
> 'conditions' => array('Post.category_id' => $id)
> )
> );
> $this->set('posts', $this->paginate('Post'));
That worked nicely.
> ...
> HTH, Paul.
Well it did help but I have one unnecessary query left, for some
reason Cake
gets all the comments for all the posts displayed:
SELECT `Comment`.`id`, `Comment`.`post_id`, `Comment`.`name`,
`Comment`.`content`, `Comment`.`created`, `Comment`.`modified` FROM
`comments` AS `Comment` WHERE `Comment`.`post_id` IN (2, 1)
I don't need any of these comments on any of the category views. Is
there a way of stopping this query?
Thanks.
--
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
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php