steerCMSCommentPlugin

Commenting can be added to any Propel object as a behavior via the steerCMSCommentPlugin. In addition, this plugin also provides a component to display the comment form, backend module for comment approval and spam detection class.

Adding the Behavior

Activating this plugin is a simple task of adding the following code to your Propel objects class:

sfPropelBehavior::add('steerCMSBlogPost', array('steerCMSCommentBehavior'));

Once that is in place, your object will have access to the following methods:

  • addComment: add a single comment.
  • deleteComments: delete all comments attached to an object.
  • getComments: retrieve all comments attached to an object.
  • deleteComment: delete a single comment attached to an object.

To enhance you interface to include the comment form, you simple call a component:

include_component('steerCMSComment', 'form', array('object' => $post));

Enabling and Disabling Comments

When an attempt to add a comment is made, the steerCMSCommentPlugin will check for authorisation from the base object. This is done by checking for a comments_enabled() method. So if you would like to have you objects regulate a comments enabled or disabled context, it can be communicated to the comments behavior - take a look at steerCMSBlogPost model to see an implementation.

Modules

Two modules make up this plugin: steerCMSComment and steerCMSCommentAdmin - the first for components and frontend logic, the second for administration.

Routing

This plugin adds its own routing rules via its config/config.php file. These include (in order):

  • @steerCMSComment_add_authenticated → /steerCMSComment/add_authenticated
  • @steerCMSComment_add_anonymous → /steerCMSComment/add_anonymous

steerCMSCommentTools

Only in its early stages, we aim to include some spam elimination tools within this class.