I have a field_slides paragraph field on my home page, on drupal 9.1.3. It is for rendering a carousel. I want to iterate over the elements of the paragraph field (eg the slides with title, description and button fields). I'm using drupal_field twig tweak function for the sake of translability. I have tried something like the following :
{% for slide in element['#items'] %}
<div class="carousel-item {% if loop.index0 == 0 %}active{% endif %}">
<img class="d-block w-100" src="{{ file_url(slide.entity.field_illustration[0].entity.fileuri) }}" alt="First slide">
<div class="carousel-caption d-md-block w-50">
<h5 class="carousel-title" onload="animateCarouselTitle(ev)">{{ drupal_field('field_titre', 'node', {{ slide.entity.nid }}) }}</h5>
<p class="carousel-bouton">{{ drupal_field('field_bouton', 'node', {{ slide.entity.nid }}) }}</p>
<p>{{ drupal_field('field_corps', 'node', {{ slide.entity.nid }}) }}</p>
</div>
</div>
{% endfor %}
Any idea on how to dynamically get the nid of the paragraph entity in the drupal_field
function?
paragraph id
or are you truly looking forNID
, i.e. thenode id
which as above commenter mentions is nowid
in D8 & 9.