Answer the question
In order to leave comments, you need to log in
How to check the number of records in the database in TWIG?
Before executing the loop, I first need to check:
If there are many records (more than 1), then we output the cycle, if less, then we also output it but a little differently.
{% if records > 1 %} does not work))
How can this be done? I can't find something.
An example of the code to be executed if there are more than 1 records
{% if record %}
<h2>{{ record.name }}</h2>
{% else %}
{% endif %}
{% if record %}
<h1>{{ record.name }}</h2>
{% else %}
{% endif %}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question