I try to build an accordion or slider element with Paragraphs.
Therefore I create a Slider element which had slides. Unfortunately the first element should always looks different. I can do this with a CSS class, but how to figure out which is the first slide?
Slider:
<div class="feature-slider">
<div class="feature-slider__slides">
<div class="feature-slider__slides-container">
{{ content.field_feature_slider_slides }}
</div>
</div>
</div>
Slide (which will loaded through Drupal Magic):
<div class="feature-slide {% if pos == 1 %}feature-slide--active{% endif %}">
...
</div>
How can I get/set/access a variable (here pos) with the current position of the loop?
The Slider uses Paragraphs to add several Slides. The is a template for the slider paragraph--slider.html.twig and paragraph--slide.html.twig for the slides. No For-Loops are involved here. Drupal/Paragraphs rendering the slides through the template with content.field_feature_slider_slides from the slider.