Hi Guys,
I just wanted to share some stuff that I've learned. :)
First off, you can enable Page Comments by editing a page, clicking on the "Behaviour" tab, checking the box next to "Allow comments on this page?", and saving the page.
By default, Page Comments do not have any protection against spam. This means that your pages can become spammed by robots.
One thing you can do is use the SSAkismet class to use spam detection for comments using http://akismet.com/
For more info on how to do this see: http://doc.silverstripe.com/doku.php?id=ssakismet
However, I did not follow the above instructions because I didn't want to rely on a spam filtering service, I wanted to manually approve or delete every single comment by hand.
First I made it so that new comments are not shown by default. Here's how:
1. Open cms/code/sitefeatures/PageCommentInterface.php
2. Find this line:
$comment->IsSpam = false;
3. Replace that line with:
$comment->IsSpam = true;
Next, I needed to make the "this comment is not spam" link show up and work even though I did not enable SSAkismet. Here's how:
1. Open cms/code/sitefeatures/PageComment.php
2. Find these 3 lines:
if(SSAkismet::isEnabled() && Permission::check('CMS_ACCESS_CMSMain') && $this->getField('IsSpam')) {
return "PageComment/reportham/$this->ID";
}
3. After the above 3 lines, add these 3 lines:
if(Permission::check('CMS_ACCESS_CMSMain') && $this->getField('IsSpam')) {
return "PageComment/reportham/$this->ID";
}
4. Find these 2 lines:
$comment->setField('IsSpam', false);
$comment->write();
5. After those 2 lines, add the following 6 lines:
} else {
if (Permission::check('CMS_ACCESS_CMSMain')) {
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
$comment->setField('IsSpam', false);
$comment->write();
}
Ok, thankfully that's all the code changes we will need to make. :)
SilverStripe has a built-in RSS feed for Page Comments. You will want to subscribe to it at http://www.example.com/PageComment/rss using your favorite feed reader.
For example, the URL for my Page Comments feed is: http://www.elijahlofgren.com/silverstripe/PageComment/rss
Now when you see a new comment show up on your Page Comments RSS feed, you can do the following:
1. Login to the your SilverStripe CMS Admin Panel.
2. Visit the URL of the page where the Comment was posted (this will show up as a link in your feed reader)
3. Add ?showspam=1 to then end of the Page URL, for example:
www.example.com/your-page/?showspam=1
4. If the new comment is not spam, them click the "this comment is not spam" link under it and it will start showing up on your page.
5. If the comment is spam, click the "remove this comment" link under it and it will be deleted.
There, an easy way to implement comment moderation. :)
Enjoy,
Elijah Lofgren