pagination.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {% if DEFAULT_PAGINATION %}
  2. <div class="pagination-style-custom">
  3. <nav class="pagination is-rounded is-centered" aria-label="pagination">
  4. {% if articles_page.has_previous() %}
  5. <a class="pagination-previous button is-button-grey"
  6. href="{{ SITEURL }}/{{ articles_previous_page.url }}">{{ _('Página anterior') }}</a>
  7. {% else %}
  8. <a class="pagination-previous disabled">{{ _('Página anterior') }}</a>
  9. {% endif %}
  10. {% if articles_page.has_next() %}
  11. <a class="pagination-next button is-button-grey"
  12. href="{{ SITEURL }}/{{ articles_next_page.url }}">{{ _('Página siguiente') }}</a>
  13. {% else %}
  14. <a class="pagination-next disabled">{{ _('Página siguiente') }}</a>
  15. {% endif %}
  16. <ul class="pagination-list">
  17. {% for num in range(1, 1 + articles_paginator.num_pages) %}
  18. {% set print_number = False %}
  19. {% set dots_before = True %}
  20. {% if num == 1 %}
  21. {% set print_number = True %}
  22. {% set dots_before = False %}
  23. {% elif (articles_page.number - PAGINATOR_LIMIT / 2) <= num < (articles_page.number - PAGINATOR_LIMIT / 2 + 1) %}
  24. {% set print_number = True %}
  25. {% if num == 2 %}
  26. {% set dots_before = False %}
  27. {% endif %}
  28. {% elif (articles_page.number - PAGINATOR_LIMIT / 2 + 1) <= num <= (articles_page.number + PAGINATOR_LIMIT / 2) %}
  29. {% set print_number = True %}
  30. {% set dots_before = False %}
  31. {% elif num == articles_paginator.num_pages %}
  32. {% set print_number = True %}
  33. {% if (articles_page.number + PAGINATOR_LIMIT / 2) <= num <= (articles_page.number + PAGINATOR_LIMIT / 2 + 1)%}
  34. {% set dots_before = False %}
  35. {% endif %}
  36. {% endif %}
  37. {% if print_number %}
  38. {% if dots_before %}
  39. <li><span class="pagination-ellipsis">&hellip;</span></li>
  40. {% endif %}
  41. {% if num == articles_page.number %}
  42. <li>
  43. <a class="pagination-link is-current"
  44. aria-label="Page {{ num }}"
  45. aria-current="page">{{ num }}
  46. </a>
  47. </li>
  48. {% else %}
  49. <li>
  50. <a class="pagination-link" aria-label="Goto page {{ num }}"
  51. href="{{ SITEURL }}/{{ articles_paginator.page(num).url }}">{{ num }}
  52. </a>
  53. </li>
  54. {% endif %}
  55. {% endif %}
  56. {% endfor %}
  57. </ul>
  58. </nav>
  59. </div>
  60. {% endif %}