Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Deprecated: behavior that allows any model to be commented upon


This plugin provides an easy way to include Commentable Behavior in your application. It also integrates Miles Johnson's (@gearvosh) CommentiaBehavior ( to enable some simple moderation of each comment before posting to the database.


  • Clone from github : in your plugin directory type git clone git:// commentable
  • Add as a git submodule : in the directory containing your app, type git submodule add git:// app/plugins/commentable
  • Download an archive from github and extract it in app/plugins/commentable


  1. In a model that needs slugging, add :

    var $actsAs = array('Commentable.Commentable')
  2. Execute the SQL command contained at config/sql/comments.sql

  3. Add the following to it's controller (I'm using the Post controller as an example) :

    function comment($id = null) {
        if (!empty($this->data['Comment'])) {
            if ($this->Post->createComment($id, $this->data)){
                $this->Session->setFlash(__('Post was commented on', true), 'messages/success');
                $this->redirect(array('action' => 'view', $id), 200, true);
            } else {
                $this->Session->setFlash(__('Post could not be commented on. Perhaps you left a field empty?', true), 'messages/error');
  4. And add the following to the view (in my case the posts/view.ctp file) you'd like to comment on:

    <h2><?php __('Post a Comment'); ?></h2>
        <?php echo $form->create('Post', array('action' => 'comment')); ?>
            <legend><?php __('Add Comment');?></legend>
                echo $form->input('');
                echo $form->input('');
                echo $form->input('');
                echo $form->input('Comment.body');
    <?php echo $form->end('Submit'); ?>
Something went wrong with that request. Please try again.