Вопрос

I have a Symfony 2.1 version with a controller that returns the total of points. I am rendering this in my twig template as follows:

{%render "AdminBundle:Reports:getExpiringPoints" with {'id':dealer.id}%}

This prints the total points. I need to check that value and print it if the rendering value is greater that 0.

Is it possible in Symfony 2.1?

Это было полезно?

Решение

i found that :

    {% set x %}
        {%render "AdminBundle:Reports:getExpiringPoints" with {'id':dealer.id}%}
    {% endset %}

{% if x> 0 %}
  //display
{% endif %}

and after you can use it. Tell me if it works

Другие советы

You can check it directly in the controller or with twig :

{% if var > 0 %}
  //display
{% endif %}

Twig supports all of the standard logical operators ==, !=, <, >, >=, and <=.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top