We're off to DotAll 2022 in Brooklyn NY (plus a little extra sightseeing time). Our support will be limited.

Vote#

Users can vote on a comment, which they may agree, or disagree with. Note that only logged-in users should be able to vote on a comment.

Attributes#

AttributeDescription
idID of the vote.
commentThe Comment this vote was made on.
userThe User (opens new window) for the user who made this vote.
upvoteIf this vote was recorded as an upvote.
downvoteIf this vote was recorded as an downvote.

Up-vote a comment#

You can upvote a comment using a POST request to an action controller, and the following template code. You must supply a commentId, siteId and upvote in your form.

<form role="form" method="post" accept-charset="UTF-8">
    <input type="hidden" name="action" value="comments/comments/vote">
    <input type="hidden" name="siteId" value="{{ comment.siteId }}">
    <input type="hidden" name="commentId" value="{{ comment.id }}">
    <input type="hidden" name="upvote" value="true">
    {{ csrfInput() }}

    <button type="submit">{{ 'Upvote' | t('comments') }}</button>
</form>

Down-vote a comment#

You can downvote a comment using a POST request to an action controller, and the following template code. You must supply a commentId, siteId and downvote in your form.

<form role="form" method="post" accept-charset="UTF-8">
    <input type="hidden" name="action" value="comments/comments/vote">
    <input type="hidden" name="siteId" value="{{ comment.siteId }}">
    <input type="hidden" name="commentId" value="{{ comment.id }}">
    <input type="hidden" name="downvote" value="true">
    {{ csrfInput() }}

    <button type="submit">{{ 'Downvote' | t('comments') }}</button>
</form>

Previous ← Flag Next Events →

Get started with Comments

Available for Craft 4. Get it from the plugin store.