I
I
Ivan Shulga2021-03-15 03:37:38
Drupal
Ivan Shulga, 2021-03-15 03:37:38

Why is comparison not working in TWIG Drupal?

there is a taxonomy term field and is configured as an entity identifier in the material.
in the file field--field-name.html.twig I want to add code for a certain term, how to do this if the comparison does not work

{% for item in items %}
    {% if item.content == 13 %}
        // некий код
    {% endif %}
{% endfor %}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
afi13, 2021-03-15
@ZamarShoo

Are you sure that item.content contains 13? Usually this is an array. Use {{ dump(item.content) }} to debug and see what comes up there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question