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-cake-blog-tutorial
I have also been looking at a similar post at
http://groups.google.com/group/cake-php/browse_thread/thread/87571094869f3b92/3124e5e69c0409ed?lnk=gst&q=comments+blog+tutorial+&rnum=6#3124e5e69c0409ed

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 at
http://groups.google.com/group/cake-php/browse_thread/thread/53d01780fa0af4ce


--~--~---------~--~----~------------~-------~--~----~
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