As a newbie to cakePHP I encounter of course a lot of problems,this is
my most recent.

when debugging a view page i can see all the necessary arrays, but the
"normal" view gives me notice about unidentified variables.....


***VIEW CODE****

(line13)<? foreach($comments as $comment): ?>
                <div class="comment">
                <p><b><?=$comment['Comment']['name'];?></b></p>
                <p><?=$comment['Comment']['content'];?></p>
                </div>
        <? endforeach;?>

this is the error i'm getting :Undefined variable: comments [APP/views/
posts/view.ctp, line 13]


***CONTROLLER CODE***

<?      function view($id = null) {
                if (!$id) {
                        $this->Session->setFlash('Invalid Post');
                        $this->redirect(array('action'=>'index'));

                }
                $post = $this->Post->read(null,$id);
                $comments = $this->Post->Comment->find('all',array
('conditions'=>array('Post.id'=>$id)));
                $this->set(compact('post','comments'));
        }
?>

***DEBUG OUTPUT***

Array
(
    [Post] => Array
        (
            [id] => 10
            [name] => test10
            [date] => 2009-01-03 14:13:00
            [content] => sfgsdfgsdf
            [user_id] =>
        )

    [User] => Array
        (
            [id] =>
            [name] =>
            [email] =>
            [firstname] =>
            [lastname] =>
        )

    [Comments] => Array
        (
            [0] => Array
                (
                    [id] => 1
                    [name] => test commetn bij 10
                    [content] => test commetn bij 10
                    [post_id] => 10
                )

        )

    [Tag] => Array
        (
            [0] => Array
                (
                    [id] => 1
                    [name] => tag1
                    [longname] => taglong1
                    [PostsTag] => Array
                        (
                            [id] => 23
                            [post_id] => 10
                            [tag_id] => 1
                        )

                )

        )

)



- All necessary tables exist and are well formatted
- The project is taken from Apress.beginning.cakePHP.from.novice.....
p.140


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to