{% comment %} Composant Pagination avec DaisyUI inspiré de Flux UI Usage: {% endcomment %}
{% if simple %} {% comment %}Simple pagination: Previous/Next only{% endcomment %} {% if current_page > 1 %} Précédent {% else %} Précédent {% endif %} {% if current_page < total_pages %} Suivant {% else %} Suivant {% endif %} {% else %} {% comment %}Full pagination with page numbers{% endcomment %} {% comment %}Previous button{% endcomment %} {% if current_page > 1 %} {% else %} {% endif %} {% comment %}Page numbers logic{% endcomment %} {% if total_pages <= 7 %} {% comment %}Show all pages if 7 or fewer{% endcomment %} {% for page_num in "1234567"|make_list %} {% if page_num|add:"0" <= total_pages %} {% if page_num|add:"0" == current_page %} {{ page_num }} {% else %} {{ page_num }} {% endif %} {% endif %} {% endfor %} {% else %} {% comment %}Complex pagination for many pages{% endcomment %} {% comment %}Always show page 1{% endcomment %} {% if current_page == 1 %} 1 {% else %} 1 {% endif %} {% comment %}Show ellipsis if current page is far from start{% endcomment %} {% if current_page > 4 %} ... {% endif %} {% comment %}Show pages around current page{% endcomment %} {% for i in "-2,-1,0,1,2"|make_list %} {% with page_num=current_page|add:i %} {% if page_num > 1 and page_num < total_pages %} {% if page_num == current_page %} {{ page_num }} {% else %} {{ page_num }} {% endif %} {% endif %} {% endwith %} {% endfor %} {% comment %}Show ellipsis if current page is far from end{% endcomment %} {% with pages_from_end=total_pages|add:current_page|add:"-1"|add:"-1"|add:"-1" %} {% if pages_from_end > 3 %} ... {% endif %} {% endwith %} {% comment %}Always show last page{% endcomment %} {% if current_page == total_pages %} {{ total_pages }} {% else %} {{ total_pages }} {% endif %} {% endif %} {% comment %}Next button{% endcomment %} {% if current_page < total_pages %} {% else %} {% endif %} {% endif %}