diff --git a/config/packages/knp_paginator.yaml b/config/packages/knp_paginator.yaml new file mode 100644 index 0000000000000000000000000000000000000000..210dd6ca5113092fda09b7c3270e02ea65f92c02 --- /dev/null +++ b/config/packages/knp_paginator.yaml @@ -0,0 +1,8 @@ +knp_paginator: + page_range: 3 # number of links showed in the pagination menu (e.g: you have 10 pages, a page_range of 3, on the 5th page you'll see links to page 4, 5, 6) + default_options: + page_name: page # page query parameter name + template: + pagination: 'pagination/customized_paginator.html.twig' # sliding pagination controls template + sortable: '@KnpPaginator/Pagination/sortable_link.html.twig' # sort link template + filtration: '@KnpPaginator/Pagination/filtration.html.twig' \ No newline at end of file diff --git a/config/packages/paginator.yaml b/config/packages/paginator.yaml deleted file mode 100644 index 6b7060c91e9fc19706e692eec579d8809267b6d8..0000000000000000000000000000000000000000 --- a/config/packages/paginator.yaml +++ /dev/null @@ -1,13 +0,0 @@ -knp_paginator: - page_range: 3 # number of links showed in the pagination menu (e.g: you have 10 pages, a page_range of 3, on the 5th page you'll see links to page 4, 5, 6) - default_options: - page_name: page # page query parameter name - sort_field_name: sort # sort field query parameter name - sort_direction_name: direction # sort direction query parameter name - distinct: true # ensure distinct results, useful when ORM queries are using GROUP BY statements - filter_field_name: filterField # filter field query parameter name - filter_value_name: filterValue # filter value query parameter name - template: - pagination: '@KnpPaginator/Pagination/bootstrap_v5_pagination.html.twig' # sliding pagination controls template - sortable: '@KnpPaginator/Pagination/sortable_link.html.twig' # sort link template - filtration: '@KnpPaginator/Pagination/filtration.html.twig' \ No newline at end of file diff --git a/templates/pagination/customized_paginator.html.twig b/templates/pagination/customized_paginator.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..a7a6b974fb21e4a25f7358d6c967ca088294de14 --- /dev/null +++ b/templates/pagination/customized_paginator.html.twig @@ -0,0 +1,65 @@ +{% if pageCount > 1 %} + <nav> + {% set classAlign = (align is not defined) ? '' : align=='center' ? ' justify-content-center' : (align=='right' ? ' justify-content-end' : '') %} + {% set classSize = (size is not defined) ? '' : size=='large' ? ' pagination-lg' : (size=='small' ? ' pagination-sm' : '') %} + <ul class="pagination{{ classAlign }}{{ classSize }}"> + + {% if previous is defined %} + <li class="page-item"> + <a class="page-link" rel="prev" href="{{ path(route, query|merge({(pageParameterName): previous})) }}">«</a> + </li> + {% endif %} + + {% if startPage > 1 %} + <li class="page-item"> + <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): 1})) }}">1</a> + </li> + {% if startPage == 3 %} + <li class="page-item"> + <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): 2})) }}">2</a> + </li> + {% elseif startPage != 2 %} + <li class="page-item disabled"> + <span class="page-link">…</span> + </li> + {% endif %} + {% endif %} + + {% for page in pagesInRange %} + {% if page != current %} + <li class="page-item"> + <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): page})) }}">{{ page }}</a> + </li> + {% else %} + <li class="page-item active"> + <span class="page-link">{{ page }}</span> + </li> + {% endif %} + + {% endfor %} + + {% if pageCount > endPage %} + {% if pageCount > (endPage + 1) %} + {% if pageCount > (endPage + 2) %} + <li class="page-item disabled"> + <span class="page-link">…</span> + </li> + {% else %} + <li class="page-item"> + <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): (pageCount - 1)})) }}">{{ pageCount -1 }}</a> + </li> + {% endif %} + {% endif %} + <li class="page-item"> + <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): pageCount})) }}">{{ pageCount }}</a> + </li> + {% endif %} + + {% if next is defined %} + <li class="page-item"> + <a class="page-link" rel="next" href="{{ path(route, query|merge({(pageParameterName): next})) }}">»</a> + </li> + {% endif %} + </ul> + </nav> +{% endif %}