How do I display a block in Twig if there is data passed to it?
I have a page in a project I'm working on where I'm having a bit of a problem with.
The page displays two sets of results. The first set of results displays the information for the a project that has just been created. The second set of results displays all the reviews and revisions for this project. This is where I'm having the problem.
When the project is created, there are no reviews created. However, because I have set the page to display reviews related to the selected project, it is expecting to retrieve reviews for the selected project. As there are no reviews to ret开发者_运维百科rieve (because they haven't been added yet) the page fails and gives an ambiguous 500 error.
Now, I have seen somewhere that Twig allows if statements.But, I can't seem to work out how to make this work in my project.
Does anyone know how you would use an if statement in Twig in conjunction with a MySQL result?
I've "Twigged" it (I'm here all week)
{% if reviews == null %}
Stuff to display if the result is null
{% else %}
Stuff to display if the result isn't null
{% endif %}
The loop is then inserted inside this if statement.
精彩评论