{% set isLiveComments = isLiveComments is defined %}
{% set showBanners = showBanners is defined and not isLiveComments %}
{% for comment in comments %}
{% if isLiveComments %}
{% include 'Slivki/comments/comments_item.html.twig' %}
{% else %}
{{ _self.recursiveComment(comment, isLiveComments, 1) }}
{% if showBanners %}
<span id="commentBannerPlaceHolder{{ loop.index }}" class="hidden"></span>
{% endif %}
{% endif %}
{% endfor %}
{% if pagination is defined and pagination %}
{{ pagination|raw }}
{% endif %}
{% if hasMore and comments|length > 0 %}
<div id="afterCommentsBlock">
{% set lastEntityID = 0 %}
{% set lastComment = comments|last %}
{% if not isLiveComments %}
{% set lastEntityID = comments|last.getEntityID() %}
{% set lastComment = comments|last %}
{% endif %}
<div class="button--white" onclick="loadComments({{ lastEntityID }}, {{ lastComment.getID() }}, {{ lastComment.getTypeID() }}{{ categoryID is defined ? ', ' ~ categoryID }}{{ directorID is defined ? ', ' ~ directorID }})" id="newCommentsButtons">Ещё отзывы</div>
{% if not isLiveComments and not is_granted(constant('Slivki\\Entity\\UserGroup::COMMENTS_BANNED_ROLE_NAME')) and lastComment.getTypeID() != constant('Slivki\\Entity\\Comment::TYPE_MALL_BRAND_COMMENT') %}
<div id="bottomAddVoteLink" class="addVoteLink button">Добавить отзыв</div>
{% endif %}
</div>
{% endif %}
{% macro recursiveComment(comment, isLiveComments, level) %}
{% include 'Slivki/comments/comments_item.html.twig' %}
{% for child in comment.getChildren()|filter(child => not child.isHidden() and child.isConfirmedPhone()) %}
{{ level == 1 ? '<ul>' }}
{{ _self.recursiveComment(child, isLiveComments, level + 1) }}
{{ level == 1 ? '</ul>' }}
{% endfor %}
{% endmacro %}