De eerste bestuurder weergeven

Beste

Met deze code krijg ik al de bestuurders. {% for item in period.people %} {{ item.custom.last_name }} {{ item.custom.first_name }}

{% endfor %} ik zou gewoon de eerste moeten hebben wat pas ik aan?

Dear Olivier,

Please don’t forget all posts on our community should be in English and liquid code should be pasted in a structured way. Please read the welcome to the Silverfin community page.

To answer your question: If you want only the first loop of your forloop to be executed, you can make use of the forloop.first check within your forloop. This case tells you all about it.

Best regards,

Michiel

I have add the formula but i get nothing now?

{% if forloop.first %} {% for item in period.people %} {{ item.custom.last_name }} {{ item.custom.first_name }}

{% endfor %}

{% endif %}

Wat is not correct?

Thx

Dear Olivier,

thank you for your question.

The code may not work properly because the {% for item in period.people %} part goes after {% if forloop.first %}. You need to first determine the collection, i.e. period.people, through which {% if forloop.first %} will be run. Thus, if you swap those two components, please see the code below, then the code should work. Another tip would be to use “person” instead of “item”, as this would help you to follow the code more easily.

In addition, we would kindly ask you to use 3 backticks [```] before and after your code, when you paste part of your code to our Community page. This way, it will be easier to identify and read the code in the whole text. For more information, please follow the link: How to paste your code in a community post

{% for person in period.people %}
  {% if forloop.first %}
    {{ person.custom.last_name }}
    {{ person.custom.first_name }}
  {% endif %}
{% endfor %}

Pleae let us know if you have further questions.

Kind regards,

Irina

1 Like

Its oké Thx