문제

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