B
B
Bogdan Zhuvak2020-06-22 18:17:43
Drupal
Bogdan Zhuvak, 2020-06-22 18:17:43

How to output text in drupal loop?

I have 12 tables per page. Output in this format

<div class="portfolio_table">{{ content.field_tablica_1 }}</div>
<div class="portfolio_table">{{ content.field_tablica_2 }}</div>
<div class="portfolio_table">{{ content.field_tablica_3 }}</div>
<div class="portfolio_table">{{ content.field_tablica_4 }}</div>

etc.
I need to display this in a loop, but I don’t know how to replace the number in {{ content.field_tablica_1 }}
{% for i in range(1, 12) %}
          <div class="portfolio_table" id="portfolio_table_{{i}}">{{ content.field_tablica_1 }}</div>
{% endfor %}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
andead, 2020-06-22
@SoraxBZ

{{ content['field_tablica_' ~ i] }}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question