Is there any way to include an if condition in views footer. I have to check the total rows

{% if [view:total-rows]  > 6 %}
<div class="btn">View AllEvents</div>
{% endif %}

But this is not working.


What is the name of your template file? Depending on what template you use,

{% if view.total_rows > 6 %}
  <div ...
{% endif %}

should work.

  • 1
    If you talk about views.view.html.twig, just use "rows" instead of "view.total_rows". – Rainer Feike Nov 11 '19 at 11:19

I recommend reading this page.

Install the twig tweak module. And use the link described above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.