Hi,
posts, tags, posts_tags
Three tables.
Now how to find every post for particular tag? and how to do that pagination?
I did like this.
$this->Tag->unbindModel(array('hasAndBelongsToMany'=>array('Post')),false);
$this->Tag->bindModel(
array(
'hasOne'=>array(
'PostsTag'=>array(
'foreignKey'=>false,
'type'=>'INNER',
'conditions'=>array('PostsTag.tag_id = Tag.id')
),
'Post'=>array(
'foreignKey'=>false,
'type'=>'INNER',
'conditions'=>array(
'Post.id = PostsTag.post_id'
)
)
)
)
,false);
$this->paginate = array('conditions' => array('Post.status' => 'active','Tag.tag_value' => $name),'limit' => 10,'group' => array('Post.id'));
$tags_temp = $this->paginate('Tag');
$post_id = array();
foreach($tags_temp as $tag_array) {
$post_id[] = $tag_array['PostsTag']['post_id'];
}
So, the array will have maximum 10 post ids. Now i used
$this->Tag->Post->find to find the the posts. But the pagination is not working.
--
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
Monday, August 29, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment