bs_base-8.x-1.x-dev/templates/navigation/pager.html.twig
templates/navigation/pager.html.twig
{#
/**
* @file
* Theme override to display a pager.
*
* Available variables:
* - items: List of pager items.
* The list is keyed by the following elements:
* - first: Item for the first page; not present on the first page of results.
* - previous: Item for the previous page; not present on the first page
* of results.
* - next: Item for the next page; not present on the last page of results.
* - last: Item for the last page; not present on the last page of results.
* - pages: List of pages, keyed by page number.
* Sub-sub elements:
* items.first, items.previous, items.next, items.last, and each item inside
* items.pages contain the following elements:
* - href: URL with appropriate query parameters for the item.
* - attributes: A keyed list of HTML attributes for the item.
* - text: The visible text used for the item link, such as "‹ Previous"
* or "Next ›".
* - current: The page number of the current page.
* - ellipses: If there are more pages than the quantity allows, then an
* ellipsis before or after the listed pages may be present.
* - previous: Present if the currently visible list of pages does not start
* at the first page.
* - next: Present if the visible list of pages ends before the last page.
*
* @see template_preprocess_pager()
*
* @ingroup themeable
*/
#}
{% set page_link_classes = 'page-link' %}
{% set page_link_active_classes = page_link_classes %}
{% set page_link_ellipses_classes = 'page-ellipses' %}
{% block items %}
{{ attach_library('bs_lib/pagination') }}
{% if items %}
<nav {{ attributes }}>
<ul class="pagination js-pager__items">
{# Print first item if we are not on the first page. #}
{% if items.first %}
{% block items_first %}
<li class="page-item page-item--first">
<a class="{{ page_link_classes }}" href="{{ items.first.href }}"{{ items.first.attributes|without('href') }}>
<span class="visually-hidden">{{ 'First page'|t }}</span>
<span aria-hidden="true">{{ items.first.text|default('« First'|t) }}</span>
</a>
</li>
{% endblock %}
{% endif %}
{# Print previous item if we are not on the first page. #}
{% if items.previous %}
{% block items_previous %}
<li class="page-item page-item--previous">
{# There is no such thing as items.previous.attributes for now.
However classy is rendering it so we will do it also. #}
<a class="{{ page_link_classes }}" href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('class', 'href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Previous page'|t }}</span>
<span aria-hidden="true">{{ items.previous.text|default('‹ Previous'|t) }}</span>
</a>
</li>
{% endblock %}
{% endif %}
{# Add an ellipsis if there are further previous pages. #}
{% if ellipses.previous %}
{% block elipses_previous %}
<li class="page-item page-item--ellipsis"><span class="{{ page_link_ellipses_classes }}">…</span></li>
{% endblock %}
{% endif %}
{# Now generate the actual pager piece. #}
{% for key, item in items.pages %}
{% block items_pages %}
<li class="page-item{{ current == key ? ' active' : '' }}">
<a class="{{ current == key ? page_link_active_classes : page_link_classes }}" href="{{ item.href }}"{{ item.attributes|without('href') }}>
{{ key }}
</a>
</li>
{% endblock %}
{% endfor %}
{# Add an ellipsis if there are further next pages. #}
{% if ellipses.next %}
{% block elipses_next %}
<li class="page-item page-item--ellipsis"><span class="{{ page_link_ellipses_classes }}">…</span></li>
{% endblock %}
{% endif %}
{# Print next item if we are not on the last page. #}
{% if items.next %}
{% block items_next %}
<li class="page-item page-item--next">
{# There is no such thing as items.next.attributes for now.
However classy is rendering it so we will do it also. #}
<a class="{{ page_link_classes }}" href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('class', 'href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Next page'|t }}</span>
<span aria-hidden="true">{{ items.next.text|default('Next ›'|t) }}</span>
</a>
</li>
{% endblock %}
{% endif %}
{# Print last item if we are not on the last page. #}
{% if items.last %}
{% block items_last %}
<li class="page-item page-item--last">
<a class="{{ page_link_classes }}" href="{{ items.last.href }}"{{ items.last.attributes|without('href') }}>
<span class="visually-hidden">{{ 'Last page'|t }}</span>
<span aria-hidden="true">{{ items.last.text|default('Last »'|t) }}</span>
</a>
</li>
{% endblock %}
{% endif %}
</ul>
</nav>
{% endif %}
{% endblock %}
