Oh, right, gotcha. You're mixing up normal view variables (here
$post), the view $data variable and the $this->data. Basically, $this-
>data is the one that is automatically filled and works with forms
(filled through $_GET or $_POST). The $data variable is generally used
as a catch-all for the view, possibly a mirror of $this->data. But
you're not setting $data or $this->data, you're setting $post. So...

You need to change your view code to this:

------------------Post View------------------
<p><?php echo $post['Post']['body']?></p>
<?php
debug($post);
if (isset($post['Comment']))
{
    foreach ($post['Comment'] as $Comment)
    {
    echo "<div class=\"commentbody\">";
    echo $comment['body'];
    echo "</div>";
    echo "<div class=\"commenttitle\">";
    echo "written by ".$comment['user_id']."
         ".$time->timeAgoInWords($comment['created']);
    echo "</div>";
    }

}

else
{
    echo "No comments yet.";

}

?>

On Oct 11, 4:13 pm, seacloud9 <[EMAIL PROTECTED]> wrote:
> Tried that and still nothing.  It doesn't seem to be passing any data
> in the data area??  Really perplexed.
> I have a debug in their and it retrieves nothing??  It is odd that I
> can save the information yet not retrieve it...
> debug($this->data);
>
> I think it might have something to do with this line in the post
> model..
>         function beforeSave()
>         {
>                 if (empty($this->id))
>                 {
>                         $this->data[$this->name]['url'] = 
> $this->getUniqueUrl($this->data[$this->name]['title'], 'url');
>
>                 }
>
>                 return true;
>         }
>
> On Oct 11, 9:56 am, grigri <[EMAIL PROTECTED]> wrote:
>
> > Looks like
>
> > foreach ($data['Comment'] as $Comment)
>
> > should be
>
> > foreach ($data['Comment'] as $comment)
>
> > On Oct 11, 3:23 pm, seacloud9 <[EMAIL PROTECTED]> wrote:
>
> > > My blog will take comments place them in the database but not display
> > > them.
>
> > > Something appears to be wrong with this code:
> > > -------------------Post View------------------
> > > <p><?php echo $post['Post']['body']?></p>
> > > <?php
> > > debug($this->data);
> > > if (isset($data['Comment']))
> > > {
> > >     foreach ($data['Comment'] as $Comment)
> > >     {
> > >     echo "<div class=\"commentbody\">";
> > >     echo $comment['body'];
> > >     echo "</div>";
> > >     echo "<div class=\"commenttitle\">";
> > >     echo "written by ".$comment['user_id']."
> > >          ".$time->timeAgoInWords($comment['created']);
> > >     echo "</div>";
> > >     }
>
> > > }
>
> > > else
> > > {
> > >     echo "No comments yet.";
>
> > > }
>
> > > ?>
>
> > > -------------------------------
> > > It is not displaying the comments it is saving them.  I have the
> > > comments associated with the foreign key post_id, I have implmented
> > > clean url on my blog following this tutorial
>
> > >http://bakery.cakephp.org/articles/view/adding-friendly-urls-to-the-c...
> > > I have also been looking at a similar post 
> > > athttp://groups.google.com/group/cake-php/browse_thread/thread/87571094...
>
> > > I am not sure what I am doing wrong I am able to save the information
> > > not display it..?  I believe it has something to do with the clean
> > > urls.
>
> > > Post Controller:
> > > function view($url)
> > > {
> > >     $post = $this->Post->findByUrl($url);
> > >         $this->set('post', $post);
>
> > > }
>
> > > Post Model
> > > <?php
> > > class Post extends AppModel
> > > {
> > >         var $name = 'Post';
>
> > >         var $validate = array(
> > >                 'title'  => VALID_NOT_EMPTY,
> > >                 'body'   => VALID_NOT_EMPTY
> > >         );
>
> > >         function beforeSave()
> > >         {
> > >                 if (empty($this->id))
> > >                 {
> > >                         $this->data[$this->name]['url'] = 
> > > $this->getUniqueUrl($this->data[$this->name]['title'], 'url');
>
> > >                 }
>
> > >                 return true;
> > >         }
> > >                 var $hasMany = array(
> > >                         'Comment' =>
> > >                                 array('className' => 'Comment',
> > >                                                 'foreignKey' => 'post_id',
> > >                                                 'order' => 
> > > 'Comment.created DESC',
> > >                                                 'dependent' => true
> > >                                 ),
> > >         );}
>
> > > ?>
>
> > > to see more of the code you can look 
> > > athttp://groups.google.com/group/cake-php/browse_thread/thread/53d01780...


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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