Only first indented comment is displayed when using template

Created on 6 February 2023, over 1 year ago
Updated 27 February 2023, over 1 year ago

Problem/Motivation

My case is that I wish to show an advert every 3 comments. However between this module and my template, only the first indented comment gets shown. The others are there in the markup but the display:none; style attribute doesn't get removed upon clicking the link. Only on the first indented comment.

If I disable this module, everything is as expected. All comments are shown, with my ads every 3 comments.

Steps to reproduce

I'm using the this in my template field--comment-forum.html.twig

{% if comments and not label_hidden %}
    
  <div class="my-5 col-print-12" id="comment-container"> 
    <section{{ attributes.addclass(classes) }}>
      {{ title_prefix }}
      <h2{{ title_attributes.addClass(title_classes) }} {{ attributes.setAttribute('id', 'comments') }}>{{ label }}</h2>
      {{ title_suffix }}
      
          {% set pre_render = comments['#pre_render'] %}
            {% for key, item in comments if key|first != '#'%}
                {% if key != 'pager' %}
                    {% set item = { '#pre_render': pre_render, 0: item } %}
                    {% if loop.index0 is divisible by(3) %}
                        {{ item }}
                        <div class="ads">{{ drupal_entity('block_content', '5') }}</div>
                    {% else %}
                        {{ item }}
                    {% endif %}
                {% else %}
                  <div class="comment-pager">{{ item }}</div>
                {% endif %}
          {% endfor %}
    </section>
  </div>
{% endif %}
πŸ’¬ Support request
Status

Closed: works as designed

Version

1.2

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom gMaximus

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024