Comments for any content
Related classes:
AJAX comments for any content. Self moderated - users rate all comments, and if comment is below viewing treshold it is hidden by default.
To add comments section to your module you need to add a record to 'sys_objects_cmts' table:
- ID - autoincremented id for internal usage
- ObjectName - your unique module name, with vendor prefix, lowercase and spaces are underscored
- TableCmts - table name where comments are stored
- Html - 0 - convert new lines to
on saving, 1 - standard(default) visual editor, 2 - full visual editor, 3 - mini visual editor.
- PerView - number of comments on a page
- IsRatable - 0 or 1 allow to rate comments or not
- ViewingThreshold - comment viewing treshost, if comment is below this number it is hidden by default
- IsOn - is this comment object enabled
- RootStylePrefix - toot comments style prefix, if you need root comments look different\
- ObjectVote - Vote object name to process comments' votes. May be empty if Comment Vote is not needed.
- TriggerTable - table to be updated upon each comment
- TriggerFieldId - TriggerTable table field with unique record id of
- TriggerFieldComments - TriggerTable table field with comments count, it will be updated automatically upon eaech comment
- ClassName - your custom class name if you need to override default class, this class must have the same constructor arguments
- ClassFile - file where your ClassName is stored.
You can refer to BoonEx modules for sample record in this table.
Example of usage
After filling in the table you can show comments section in any place, using the following code:
$o =
new BxTemplCmts(
'value of ObjectName field', $iYourEntryId);
if ($o->isEnabled())
echo $o->getCommentsBlock ();
Please note that you never need to use BxDolCmts class directly, use BxTemplCmts instead. Also if you override comments class with your own then make it child of BxTemplCmts class.
Memberships/ACL:
- comments post
- comments edit own
- comments remove own
- comments edit all
Alerts(hooks)
Alerts type/unit - every module has own type/unit, it equals to ObjectName.
The following alerts are rised
- commentPost - comment was posted
- $iObjectId - entry id
- $iSenderId - author of comment
- $aExtra['comment_id'] - just added comment id
- commentRemoved - comments was removed
- $iObjectId - entry id
- $iSenderId - comment deleter id
- $aExtra['comment_id'] - removed comment id
- commentUpdated - comments was updated
- $iObjectId - entry id
- $iSenderId - comment deleter id
- $aExtra['comment_id'] - updated comment id
- commentRated - comments was rated
- $iObjectId - entry id
- $iSenderId - comment rater id
- $aExtra['comment_id'] - rated comment id
- $aExtra['rate'] - comment rate 1 or -1