The dmCommentPlugin allows to add comments to your records.
It packages
- a Doctrine behaviour, "DmCommentable"
- two front widgets: "Form" and "Page comments"
- an admin interface to manage comments
Integrates recaptcha validation.
git clone git://github.com/ornicar/dmCommentPlugin.git plugins/dmCommentPlugin
class ProjectConfiguration extends dmProjectConfiguration { public function setup() { parent::setup(); $this->enablePlugins(array( // your enabled plugins 'dmCommentPlugin' ));
php symfony doctrine:generate-migrations-diff
php symfony doctrine:migrate
php symfony dm:setup
As this plugin is intended to provide commentable capabilities to your models, the first thing to do is declare that a model act as DmCommentable.
In this documentation we will assume we have an Article model.
schema.yml
Article:
actAs:
DmCommentable:
Then, in a console, from your project root dir, run:
php symfony dm:setup
The article model now has some additional methods to manipulate the comments:
// get active comments (with is_active field = true) $comments = $article->getComments(); // get all comments, active and inactive $comments = $article->getAllComments(); // get the number of comments $nbComments = $article->getNbComments();
The DmComment model has a method to fetch the record it is linked to:
$article = $comment->getRecord();
In Admin menu->Content->Feedback->Comments, you can manage the comments list.
As for any symfony plugin, you can copy and paste files from the plugin to your app and modify them.
The more usefull file is generator.yml. Copy
plugins/dmCommentPlugin/modules/dmCommentAdmin/config/generator.yml
to
apps/admin/modules/dmCommentAdmin/config/generator.yml
to modify it.
Add a comments partial to the list display of your article admin module generator file:
apps/admin/modules/article/config/generator.yml
...
list:
display:
- =title
- _comments # insert a comments partial here
- is_active
- created_at
- updated_at
...
Then add the comments partial in
apps/admin/modules/article/templates/_comments.php
include_partial('dmCommentAdmin/comments', array('record' => $article));
Go on an article page, open the "Add" menu, find the "comment/page comments" widget, take it and drop it on the page. Only active comments are shown.
Go on an article page, open the "Add" menu, find the "comment/form" widget, take it and drop it on the page.
This step is facultative, but will help you fighting against spam.
Add this configuration in
apps/front/config/app.yml
all:
recaptcha:
# get your recaptcha keys on http://recaptcha.net/api/getkey
public_key: 6LeefAkAAAAAAF-this-is-a-dummy-public-key
private_key: 6LeefAkAAAAAA-this-is-a-dummy-private-key
enabled: true
You will need to get API keys from the recaptcha website. It's free.
You may just use CSS if the default outputed HTML looks fine to you.
Or you can override the form template by copying
dmCommentPlugin/modules/dmComment/templates/_form.php
to
apps/front/modules/dmComment/templates/_form.php
Copy
dmCommentPlugin/modules/dmComment/templates/_form.php
to
apps/front/modules/dmComment/templates/_form.php
you can override the DmComment model in your project
lib/model/doctrine/dmCommentPlugin/DmComment.class.php
and the DmCommentForm form in your project
lib/form/doctrine/dmCommentPlugin/DmCommentForm.class.php
Listen to the 'dm_comment.saved' event in
apps/front/config/frontConfiguration.class.php
require_once(dm::getDir().'/dmFrontPlugin/lib/config/dmFrontApplicationConfiguration.php'); class frontConfiguration extends dmFrontApplicationConfiguration { public function configure() { $this->dispatcher->connect('dm_comment.saved', array($this, 'listenToCommentSavedEvent')); } public function listenToCommentSavedEvent(sfEvent $e) { $comment = $e['comment']; // do something with the freshly saved $comment } }
Open issues
Closed issues
dmCommentPlugin, created on February 3, 2010 by Thibault D, used by 467 projects
выапываDecember 20, 2010 3:39 PM
у5кен и45г 457
testJanuary 22, 2011 2:18 PM
test
SgnxMay 28, 2011 11:12 PM
tester
<anonymous>July 5, 2011 1:49 PM
You certainly have some agreeable opinions and views. Your blog provides a fresh look at the subject.
claireAugust 20, 2011 12:34 AM
Encuentro que no sois derecho. Soy seguro. Escriban en PM, discutiremos.
http://eru1.myftp.biz/
oamar
Крутой блогDecember 24, 2011 3:56 PM
<a href="http://cyberapp.ru">Kohana 3</a>