My apologies for not explaining better:
Controller:
The view has the following:
$this->set('author', $this->Author->read(null, $id));
The View Contains the Following
<?php
$i = 0;
foreach ($author['Post'] as $post):
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
}
?>
<tr<?php echo $class;?>>
<td><?php $post['name'] ?></td>
<td><?php ?></td>
****This is where I want all the tags for this post but I can't figure out
how what is the array/variable (IE something like... $post['Tags']['name']
<td><?php echo $post['created'];?></td>
<td><?php echo $post['modified'];?></td>
</tr>
<?php endforeach; ?>
The relationships in the models are setup correctly because the scaffold works
without a problem. I just want to display the data in the Authors page.
On Jan 31, 2011, at 9:37 PM, Dr. Tarique Sani wrote:
> Your Author model needs to be related to Post model - Author hasMany Post and
> then
>
> $this->set('author', $this->Author->read(null, $id));
>
> Do a debug on your author array in your view and figure out what is happening
> :-)
>
> Cheers
> Tarique
>
>
>
> 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] For more options, visit this group at
> http://groups.google.com/group/cake-php
>
>
>
> --
> =============================================================
> Cheesecake-Photoblog: http://cheesecake-photoblog.org
> PHP for E-Biz: http://sanisoft.com
> =============================================================
>
> --
> 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
--
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