How it works

Xcomm3x1 min readPage 11 of 11
On this page 4

Frontend

The JS file (xcomm3x.js) reads its configuration from window.Xcomm3xConfigs, generated by the Xcomm3x and XcommThread snippets. The config holds the connector URL and the names of all chunks for AJAX rendering.

All interactive elements are marked with data-xc-* attributes — JS works only through them, not through CSS classes. This lets you use any CSS framework without changing the logic.

Main data-xc-* attributes:

AttributeWherePurpose
data-xc-threadthread wrappermount point; holds data-resource-id and data-block-key
data-xc-formcomment formsubmission is tracked
data-xc-comment="ID"comment elementidentification for AJAX updates
data-xc-reply="ID"“Reply” buttonopens the reply form
data-xc-edit="ID"“Edit” buttonopens the edit form
data-xc-delete="1"“Delete” buttonstarts deletion
data-xc-load-more="1"pagination buttonloads the next portion

Backend

All frontend requests go to the public connector assets/components/xcomm3x/connector.php. The connector checks the CSRF token (session-based, passed in window.Xcomm3xConfigs) and routes requests to processors.

The manager page uses a separate connector, assets/components/xcomm3x/htmx-connector.php — it is available only to logged-in MODX managers and only for HTMX/AJAX requests.

Database tables

TablePurpose
xcomm3x_commentcomments: text, author, status, rating, depth, path (for the tree)
xcomm3x_comment_votecomment votes (one vote per visitor)
xcomm3x_publication_votepage votes
xcomm3x_mail_queueemail notification queue: status, attempts, send time
xcomm3x_mail_unsubscribeunsubscriptions by email and channel
xcomm3x_stopwordstop words with the reaction mode
xcomm3x_blocked_ipblocked IPs and CIDR masks

Comment lifecycle

  1. Posting — Fetch POST to connector.php?action=Web/PostComment
  2. Validation — CSRF, rate limit, IP blocks, stop words, CAPTCHA, honeypot
  3. Saving — status pending (with moderation) or approved (without)
  4. Notifications — records in xcomm3x_mail_queue for all subscribed channels
  5. Rendering — if approved right away, the server returns the HTML of the new comment via the commentTpl chunk; JS inserts it into the thread without reloading the page