Comments Work v1.1.5
Easy to use commenting for Craft CMS
More Craft plugins

Integrate a comment form

Below is an example of how to set up a commenting form in Bootstrap 4.

{# @var commentsWork \twentyfourhoursmedia\commentswork\services\CommentsWorkService #}
{% set commentsWork = craft.commentsWork.service %}

{% if not currentUser and not commentsWork.allowAnonymous(entry) %}
    <p>Anonymous commenting is not allowed. Please login.</p>
{% else %}
    <div class="card bg-light">
        <div class="card-header">
            Leave a comment
        <div class="card-body">
            <form method="post" action="{{ url('/actions/comments-work/default/post-comment') }}">
                {{ csrfInput() }}
                {{ signCommentForm(entry) }}
                <input name="redirect" value="{{ }}#comments" type="hidden"/>
                <input name="elementId" value="{{ }}" type="hidden"/>
                <input name="siteId" value="{{ entry.siteId }}" type="hidden"/>
                <input name="commentFormat" value="text" type="hidden"/>

                <div class="form-group">
                    <label for="comment-title">Title</label>
                    <input name="title" id="comment-title" type="text" class="form-control"/>
                <div class="form-group">
                    <label for="comment-content">Comment</label>
                    <textarea name="comment" rows="5" id="comment-content" class="form-control"></textarea>

                    <input type="submit" class="btn btn-primary" value="Post comment"/>
{% endif %}