开发者

Cannot display comments with CakePHP Comments Plugin

开发者 https://www.devze.com 2023-03-19 11:50 出处:网络
I have the CakePHP Comments Plugin set-up correctly, I believe.I\'ve followed the poorly-written instructions [here] to the point where it\'s requiring me to login to add a comment.When I click \"add

I have the CakePHP Comments Plugin set-up correctly, I believe. I've followed the poorly-written instructions [here] to the point where it's requiring me to login to add a comment. When I click "add a comment", it gives me the title and body form fields.

It's even submitting and saving the data just fine. Then, the data comes across when I debug($article); - I see the comment(s) for that article in the data.

But - the only thing that appears when I have this in my view:

<? $commentWidget->options(array('allowAnonymousComment' => false));?>
<? echo $commentWidget->display();?>

Is the "Add a comment" button.

How do I display the comments? The plugin has views for index, edit, view...etc all seem to be laid out ok and for me to use, but... I tried a straight include, and it's missing lots of variables..etc, so - assume there's some kind of method or something to display the comments, like... echo $commentWidget->comments; or something?

UPDATE:

When I debug($result); from comment_widget.php, I still just get an "Add comment" link (so there are two on the page now - one from the actual ->display() and one from my new debug.

Below is what I'm getting when I debug($article); from my articles_controller.php. I built the table myself, based on a few th开发者_StackOverflow中文版ings I found online - and it appears to be populating (mostly) - maybe I did something wrong w/ the db setup?

[Comment] => Array
    (
        [0] => Array
            (
                [id] => 7
                [title] => dave test 2
                [created] => 2011-07-10 20:28:31
                [modified] => 2011-07-10 20:28:31
                [user_id] => 67
                [foreign_key] => 683
                [approved] => 1
                [slug] => dave_test_2
                [body] => test
                [rght] => 2
                [model] => Article
                [is_spam] => 
                [lft] => 1
                [parent_id] => 0
                [author_name] => 
                [author_url] => 
                [author_email] => 
                [language] => en-us
                [comment_type] => 
            )

        [1] => Array
            (
                [id] => 8
                [title] => blah blah blah 6523dkaljlkfsjdsfaljsd
                [created] => 2011-07-10 21:33:43
                [modified] => 2011-07-10 21:33:43
                [user_id] => 67
                [foreign_key] => 683
                ...


Build the table structure per the schema.php (plugins/comments/config/schema/schema.php) making sure to use their default values. In my case, I left out the default values of 'comment' for comment_type, and 'clean' for the default of is_spam.

Fixing both of these makes it so the comments now appear correctly! They're ugly with no CSS, so - any suggestions on that is more than welcome, but... they work!

0

精彩评论

暂无评论...
验证码 换一张
取 消