pagination.html 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {% if DEFAULT_PAGINATION %}
  2. <nav class="mt-5">
  3. <ul class="pagination pagination-circle pg-red justify-content-center">
  4. <!-- Previous -->
  5. {% if articles_page.has_previous() %}
  6. <li class="page-item">
  7. <a href="{{ SITEURL }}/{{ articles_previous_page.url }}" class="page-link" aria-label="Previous">
  8. <span aria-hidden="true">&laquo;</span>
  9. </a>
  10. </li>
  11. {% else %}
  12. <li class="page-item disabled">
  13. <a class="page-link" aria-label="Previous">
  14. <span aria-hidden="true">&laquo;</span>
  15. </a>
  16. </li>
  17. {% endif %}
  18. <!-- /Previous -->
  19. {% for num in range(1, 1 + articles_paginator.num_pages) %}
  20. {% set print_number = False %}
  21. {% set dots_before = True %}
  22. {% if num == 1 %}
  23. {% set print_number = True %}
  24. {% set dots_before = False %}
  25. {% elif (articles_page.number - PAGINATOR_LIMIT / 2) <= num < (articles_page.number - PAGINATOR_LIMIT / 2 + 1) %}
  26. {% set print_number = True %}
  27. {% if num == 2 %}
  28. {% set dots_before = False %}
  29. {% endif %}
  30. {% elif (articles_page.number - PAGINATOR_LIMIT / 2 + 1) <= num <= (articles_page.number + PAGINATOR_LIMIT / 2) %}
  31. {% set print_number = True %}
  32. {% set dots_before = False %}
  33. {% elif num == articles_paginator.num_pages %}
  34. {% set print_number = True %}
  35. {% if (articles_page.number + PAGINATOR_LIMIT / 2) <= num <= (articles_page.number + PAGINATOR_LIMIT / 2 + 1)%}
  36. {% set dots_before = False %}
  37. {% endif %}
  38. {% endif %}
  39. {% if print_number %}
  40. {% if dots_before %}
  41. <li><span class="pagination-ellipsis">&hellip;</span></li>
  42. {% endif %}
  43. {% if num == articles_page.number %}
  44. <li class="page-item active">
  45. <a class="page-link"
  46. aria-label="Page {{ num }}">{{ num }}</a>
  47. </li>
  48. {% else %}
  49. <li class="page-item">
  50. <a class="page-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. <!-- Next -->
  58. {% if articles_page.has_next() %}
  59. <li class="page-item">
  60. <a href="{{ SITEURL }}/{{ articles_next_page.url }}" class="page-link" aria-label="Next">
  61. <span aria-hidden="true">&raquo;</span>
  62. </a>
  63. </li>
  64. {% else %}
  65. <li class="page-item disabled">
  66. <a class="page-link" aria-label="Next">
  67. <span aria-hidden="true">&raquo;</span>
  68. </a>
  69. </li>
  70. {% endif %}
  71. <!-- /Next -->
  72. </ul>
  73. </nav>
  74. {% endif %}