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

Show comment entries

This code renders 10 comments for the entry.


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

<div id="comments">
    <br/>
    <p>{{  commentsWork.countComments(entry) }} comments</p>

    {% set comments = commentsWork.fetchComments(entry, 0, 10) %}
    {% for comment in comments %}
        {# @var comment \twentyfourhoursmedia\commentswork\models\CommentModel #}
        <div class="card card bg-light">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-2">
                        <img src="https://image.ibb.co/jw55Ex/def_face.jpg" class="img img-rounded img-fluid" width="64">
                        <p class="text-secondary text-center">{{ comment.dateCreated | date }} {{ comment.dateCreated | date('H:i') }}</p>
                    </div>
                    <div class="col-md-10">
                        {%- if comment.user %}<p><a href="https://maniruzzaman-akash.blogspot.com/p/contact.html"><strong>{{ comment.user.friendlyName }}</strong></a></p>{% endif -%}
                        {%- if comment.title is not empty %}
                            <p><strong>{{ comment.title }}</strong></p>
                        {% endif -%}
                        {%- if comment.comment is not empty %}
                            <p>
                                {{ comment | commentAsHtml }}
                            </p>
                        {% endif -%}
                    </div>
                </div>
            </div>
        </div>
        <br/>
    {% endfor %}
</div>