Wednesday 29 September 2010 2:29:02 pm
By : Bayron Guevara
Previously to the launching of the Ez Comments extension, we needed to implement commenting system through to a custom comment class and configure a pre-publish trigger to enable pre-moderation. The UI for comments managment was ugly and approving or denying multiple comments was a painless task, and unless you were using an extension like power_content you didn't can put the comment form inside the article or post.
Ez Comments comes to improve usability and efficiency by using their own database tables for store comments, subscription information among other things. Now it's included together with Ez Publish 4.3 or above.
First of all, you can look up the official Ez Publish documentation here and found a more detailed reference. I also recommend the official page project to get the latest announcements, bug-fixes and releases . This post pretend to be more simplified, nevertheless it covers some topics related to deployment issues.
1. Get the source code
The latest version is 1.1 at the time of writing this post. You can download it from here. Maybe you want to get the latest commits and cutting edge developments, in this case open your favorite SVN client and checkout the trunk branch. On *unix enviroments you'd make this:
svn co http://svn.projects.ez.no/ezcomments/trunk/ ezcomments
On Windows systems I recommend Tortoise as the SVN client, you can see the official site http://tortoisesvn.tigris.org/ for installation and usage instructions.
2. Install the database tables
Once you've copied the extension files in the extension directory of your ezpublish site, you need execute the SQL script that comes with the extension in order to install the database tables, so if you have MySQL run the script located at:
</path/to/your/ezpublish/root/directory>/extension/ezcomments/sql/mysql/schema.sql
Change mysql by your Database administration server. The possible options are oracle, postgre or mysql.
3. Activate the Extension
You can activate the extension either from the Administration Interface or editing settings/override/site.ini.append.php and adding ezcomments to the AvailableExtensions array.
Then re-generate the autoload array in case you've edited the file manually. To do this execute the following command:
php bin/php/ezpgenerateautoloads.php -e
And last clear all the caches.
4. Grant permissions
If you want this extension be available for users other than Administrators, you need to grant permission to the involved user role; for example, for the Anonymous Users you'd need to edit the Anonymous Role. Currently the comment module offers various functions, some of them like edit and remove have extended limitations to specify whether changes to all comments or only the owners are permitted. The functions available are:
5. Add Class Attribute and Edit Template
This extension adds a new datatype named Comment. You need to add a new attribute with this datatype to any content class you wish enable comment support, also you have to tweak templates used by these content objects. Add the following code to the respective templates:
{attribute_view_gui attribute=$node.data_map.comments}
Where comments is the respective attribute identifier.
If you wish use the notification system or the capcha valitation field in the comment forms, you need to perform the following actions.
The e-mails notifications uses the Ez Publish notification system which require be executed periodically through a cronjob on Linux or scheduled task on Windows. On Linux you can edit the crontab file by typing:
crontab -e
And adding the following line:
*/5 * * * * cd /path/to/your/ezpublish/root/directory && php runcronjobs.php -q ezcomments 2>&1
This instructs your operating system to execute the ezcomments cronjob script every 5 minutes. For a more detailed description about how to setup cronjobs in Ez Publish, see the steps listed here.
Currently recaptcha is the more common method to include CAPTCHA capabilities to your website. Basically CAPTCHA is a technique to differentiate an human from an machine through a distorted text image that need to be written in order to validate the information and prevent that bots spam the website.
To get an recaptcha account, first create a Google account and then follow the instructions showed here: https://admin.recaptcha.net/recaptcha/createsite. At the end of the process you'll receive a Public and Private Key that need to be included in the RecaptchaSetting block of an settings/ezcomments.ini.append.php override. This file would see something as:
[RecaptchaSetting] PublicKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX PrivateKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
EzComments uses some custom templates, here are the most important ones:
The template of the notification e-mail vary according to the value of ezcomments.ini.[NotificationSettings].CommentsInOne, whether it's true or false. When it's true all notifications will be send in one single email and if false an e-mail will be sent for each new comment notification. I suggest you the first option for be more efficient for and less annoying for the users.
The following templates are used when the parameter is true:
* template/comment/notification_subject.tpl
* template/comment/notification_body.tpl
And these others in case it's false:
* template/comment/notification_multi_body.tpl
* template/comment/notification_multi_subject.tpl
It's appropiate say than sometimes we need to configured the e-mail output format and this is done through the parameters ezcomments.ini.[NotificationSettings].MailContentType and ActivationEmailContentType. Here you can use the values text/plain or text/html.
Outside the Ez Publish scope, is important ensure that the notification emails aren't filter as junk or blocked at all, although each E-mail Service Provider are his own rules, you can send an email to [email protected] and get a response that brings simple checks of various sender authentication mechanisms. Also consider useful read this post http://www.comunidadhosting.com/web-hosting/5855-spf-hotmail.html
Editor Side
During the content object edition with an comment datatype, an editor can choose whether permit new comments posting or whether show the existing ones. It can be done by ticking the 'Enable commenting' and 'Show comments' checkboxes respectively.
Is important say that uncheck 'Show Comments' implies disable comments posting. For more info go to the official documentation.
Site Visitor Side
hen a visitor is authorized to view a content object with comments feature, the page present him/her a commenting form and the list of comments. The commenting form let you post a new comment from the same page unlike the traditional process that would require a redirection to a content edit form.
From the comment list you can also edit or delete comments either all or one's own according to the configured policies for the current user. For more information see http://doc.ez.no/Extensions/eZ-Comments/Setup-and-user-guide-1.1/Using-eZ-Comments/Viewing-and-posting-comments
Enabling/disabling fields
By default all the comment fields are enabled, but you can limited them to the desired ones. This is achieved by commenting out the fields listed in ezcomments.ini.append.php.[FormSettings].AvailableFields, here's an example:
[FormSettings] AvailableFields[] #AvailableFields[]=title AvailableFields[]=name #AvailableFields[]=website AvailableFields[]=email #The comment field can not be deleted! AvailableFields[]=comment AvailableFields[]=notificationField
So, only the name, email and comment will be asked in the commenting form. Also you can configure some fields behavior. Here's an example
#Make the website field required [website] Required=true PostVarName=CommentWebsite AttributeName=url
Here you probably change PostVarName -HTML input name-, but shouldn't modify AttributeName unless want to change some php files specifically classes/ezcomcomment.php
Well this is all for the moment. Stay tuned that I'll put further information soon.