Skip to content
  1. Extras
  2. resComments

resComments

Nested comments with pagination for MODX 3 resources.

Key features

  • Unlimited nesting depth
  • Multiple instances per page
  • Post rating (“star” rating)
  • Reply ratings and scoring
  • WYSIWYG editor Pell
  • Schema.org markup
  • Users can delete their own comments
  • Email notifications to the site manager, post author, and comment authors about replies
  • Pagination (with pdoPage)
  • Works without jQuery (except when used together with pdoPage)
  • Configurable toast notifications
  • Manager custom component with search, filtering, and create / delete / edit (including multi-level replies)
  • “Comments” tab for resources with selected templates
  • “Comments” tab for resources with selected IDs

System settings

ParameterDescriptionDefault
rc_antispam_fieldAnti-spam field (must be empty)comment_subject
rc_autopublishAuto-publish without moderation1
rc_notificationsScript for toast notifications.
Supports Notyf and SweetAlert2 (must be installed). You can also set miniShop3, FetchIt, or AjaxForm to reuse those components’ notifications (if installed).
Notyf
rc_js_urlPath to the JS file from the site root.{assets_url}components/rescomments/js/web/default.min.js
rc_css_urlPath to the CSS file from the site root.{assets_url}components/rescomments/css/web/default.min.css
rc_tab_tplTemplate IDs for which to show the “Comments” tab, comma-separated.
Set all to show the tab for every template; leave empty to hide it.
rc_tab_resourcesResource IDs for which to show the “Comments” tab, comma-separated.
rc_email_send_createdbyNotify the resource author about new comments (by createdby).No
rc_email_send_managerNotify managers about new comments.Yes
rc_email_send_userNotify users about replies to their comments.Yes
rc_email_subject_createdbyEmail subject to the author about a new comment on their postNew comment on your post
rc_email_subject_managerEmail subject to managers about a new commentNew comment
rc_email_subject_userEmail subject to the user about a reply to their commentReply to your comment
rc_email_tpl_createdbyChunk template for the email to the post author.rc_tpl_email_author
rc_email_tpl_managerChunk template for the email to managersrc_tpl_email_manager
rc_email_tpl_userChunk template for the email to the userrc_tpl_email_user

resComments snippet

Renders comments for a resource and loads the required scripts and styles. Call it uncached:

[[!resComments]]

With Fenom:

{'!resComments' | snippet : []}

With pdoPage:

<div id="pdopage">
    <div class="rows">
        [[!pdoPage?
            &element=`resComments`
        ]]
    </div>
    [[!+page.nav]]
</div>

Snippet properties (override system settings).

PropertyDescriptionDefault
docidResource ID.Current
topicTopic (thread). Must be unique site-wide.comments-## (## — resource ID)
allowAllAll visitors can add comments (0 — logged-in only).1
maxLevelMaximum nesting depth for comments.50
maxShiftLevelMaximum depth after which replies are no longer visually indented.10
titleComments block heading.[[%rescomments_block_title]]
addTextLabel on the “add comment” button.[[%rescomments_add]]
replyTextLabel on the “reply” button.[[%rescomments_reply]]
requiredRequired form fields.name, email, text, agree
autopublishPublish comments and replies immediately after submission1
antispamFieldAnti-spam field.comment_subject
deleteTimeSeconds during which the user can delete their own comment (if it has no reply).600
hideRepliesHide replies when the page loads.
Only top-level comments are shown. If there are replies, their count and an “Expand” button are shown.
0
sortbySort order as JSON.{"createdon":"DESC"}
limitItems per page.10
offsetOffset from the start.0
Templates
tplChunk for a single comment.rc_tpl_comment
tplWrapperChunk wrapping all comments.rc_tpl_wrapper
tplFormChunk for the add-comment form.rc_tpl_form
tplDeleteChunk for the delete button.rc_tpl_delete
tplRepliesInfoChunk for the reply count and “Expand” control.rc_tpl_replies_info
Notifications
emailToManager addresses[[++emailsender]]
emailFromNotification sender[[++site_name]]
emailManagerNotify managers about new comments.1
emailAuthorNotify post authors about new comments.1
emailUserNotify comment authors about replies to their comments.0
emailSubjectAuthorEmail subject to the author about a new comment on their post.New comment on your post
emailSubjectManagerEmail subject to managers about a new comment.New comment
emailSubjectUserEmail subject to the user about a reply to their comment.Reply to your comment
emailTplAuthorChunk for the email to the post author.rc_tpl_email_author
emailTplManagerChunk for the email to managers.rc_tpl_email_manager
emailTplUserChunk for the email to the user.rc_tpl_email_user

Chunks support standard MODX tags and Fenom. Bundled templates are styled for Bootstrap.

Plugin events

EventDescription
rcOnBeforeCreateCommentFired before a comment is created.
Receives $data — the array submitted from the form.
You may modify and return it with $modx->event->returnedValues = $data;
rcOnAfterCreateCommentFired after a comment is created. Receives $object — the new comment object.