Comparison of twig variables in if

0

I am migrating a web from drupal 7 to 8 in the course of the translation of php templates to twig language, in a logical comparison I have a variable called content [field_type] [0] which stores the type of the page, if I get this varialbe on the screen it returns a 5 but when I compare it with 5, '5' or "5" it does not return true even when doing a numerical casting of the variable, my question is Is it any type of object or field of an entity true? in this case you know some type of casting to convert it to string, also comment that in php it worked comparing with a numeric

{%if ...%}
{%elseif ...%}
{%elseif content['field_tipo'][0] == 5 %}
            {%if video%}
                <div class="tipo1">
            {%else%}
                    <div class="tipo2">
            {%endif%}
                        <div class="">
                            <div class="">
                                <h3>{{content['field_'][0]}}</h3>   
                                <h1>{{title}}</h1>
                            </div>
                            <div class="">
                                <h4>{{content['field_'][0]}}</h4>
                            </div>
                            <div class="">
                                <h4>{{content['body']}}</h4>
                            </div>
                            </div>                  
                    </div>--><!-- fin #box_tipo -->
        {%else%}
            <h1>{{content['field_tipo'][0]}}</h1><!--entro aqui y displayeo 5-->
        {%endif%}
    
asked by Jose Castillo 11.05.2018 в 10:37
source

0 answers