tilde-site/templates/includes/pagination-navigation.html

43 lines
1.2 KiB
HTML
Raw Normal View History

2023-01-25 08:55:24 +00:00
<div class="pagination-navigation">
{% set last_page_index = (paginator.total_pages - 1)/paginator.paginate_by | int + 1 %} {# it's last_index -1 actually #}
<!--
Current page : {{ paginator.current_index }}
Last page index : {{ last_page_index }}
Total pages : {{ paginator.total_pages }}-->
<ul>
<!-- First page -->
{% if paginator.current_index > 2 %}<a href="{{ paginator.first }}">
<li>1</li>
</a>{% endif %}
<!-- Previous pages ... -->
{% if paginator.current_index > 3 %}
<li>...</li>{% endif %}
<!-- Previous page -->
{% if paginator.current_index > 1 %}<a href="{{ paginator.previous }}">
<li>{{ paginator.current_index - 1 }}</li>
</a>{% endif %}
<!-- Current page -->
<li>{{ paginator.current_index }}</li>
<!-- Next page -->
{% if paginator.current_index < last_page_index %}<a href="{{ paginator.next }}">
<li>{{ paginator.current_index + 1 }}</li>
</a>{% endif %}
<!-- Next pages ... -->
{% if paginator.current_index < last_page_index - 2 %}
<li>...</li>{% endif %}
<!-- Last page -->
{% if paginator.current_index < last_page_index - 1 %}<a href="{{ paginator.last }}">
<li>{{ last_page_index }}</li>
</a>{% endif %}
</ul>
</div>