Hi,
You need to get posts alongwith their tags for a single author, right?
Attach 'containable' behavior to AppModel (or the Author model, as per your
need) and in controller's action, put the code something like
$this->Author->contain(array(
'Post' => array(
'Tag'
)
));
$this->set('author', $this->Author->findById($id));
Now, in the view, if you loop through author's posts using
foreach ($author['Post'] as $post)
then $post['Tag'] will contain the list of tags assigned to that particular
post.
Hope that helps.
Amit Badkas
PHP Applications for E-Biz: http://www.sanisoft.com
On Tue, Feb 1, 2011 at 3:49 AM, Hill180 <[email protected]> wrote:
> I am sorry for the basic question.. but here goes.
>
> I will use Blog Posts as an Example
>
> I have the following models:
>
> Author
> Post
> Tags
>
> All the associations are fine as the scaffold pages are working
> without a problem.
>
> I have a page under the Author Controller the standard view:
>
> function view($id = null) {
> if (!$id) {
> $this->Session->setFlash(__('Invalid Author',
> true));
> $this->redirect(array('action' => 'index'));
> }
> $this->set('author', $this->Post->read(null, $id))
> }
>
> In my view.ctp
>
> I want to show the author, all his/her posts and individual tags.
>
> I can easily show all the posts, but how do I get the individual tags?
>
> IE:
>
> echo $author->['Author']['name']; //good
>
> foreach ($author['Post'] as $post):
> print_r(post); //good
>
> How would I get all the tags for that specific post?
>
>
> Goal:
> Open http://localhost/authors/view/3
>
> AUTHOR: DUDE #3
> Post 5 - Tags (OPEN, IT)
> Post 10 - Tags (IT)
> Post 11 - Tags (Open)
>
> 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]<cake-php%[email protected]>For
> more options, visit this group at
> http://groups.google.com/group/cake-php
>
--
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