I’m trying to get the number of total “pager” pages with a view by using the views-mini-pager.html.twig. Here is my code so far…
{% if items.previous or items.next %}
<nav class="pagination" role="navigation">
{% if items.previous %}
{% if items.current %}
{% trans %}
<span class="page-number">Page {{ items.current }}</span>
{% endtrans %}
{% endif %}
<a class="newer-posts" href="{{ items.previous.href }}"><span aria-hidden="true">←</span>{{ items.previous.text|default('‹‹'|t) }}</a>
{% endif %}
{% if items.next %}
{% if items.current %}
{% if items.previous %}
{% else %}
{% trans %}
<span class="page-number">Page {{ items.current }}</span>
{% endtrans %}
{% endif %}
{% endif %}
<a class="older-posts" href="{{ items.next.href }}">{{ items.next.text|default('››'|t) }}<span aria-hidden="true">→</span></a>
{% endif %}
</nav>
{% endif %}
I want to have something like this
And currently, I can only get the current number page which ends up like this …
I have searched for the variables inside of views-mini-pager.html.twig and I have not found the number of pages.
My question is…
- How can I get the number of pages total? So I can display it at views-mini-pager.html.twig
- For instance, if I view is divided into three pages I want to display “Page 1 of 3”