rivet-1.0.x-dev/templates/navigation/pager.html.twig
templates/navigation/pager.html.twig
{#
/**
* @file
* Theme override to display a pager.
*
* Available variables:
* - heading_id: Pagination heading ID.
* - 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()
*/
#}
{%
set replacements = {
'‹ Previous': '',
'‹‹ Previous': '',
'Next ›': '',
'Next ››': '',
'« First': '',
'Last »': '',
'››': '',
'‹‹': '',
'«': '',
'»': '',
}
%}
{% if items %}
<nav role="navigation" aria-labelledby="{{ heading_id }}" class="rvt-m-all-lg rvt-m-all-xxl-lg-up">
<h4 id="{{ heading_id }}" class="rvt-sr-only">{{ 'Pagination'|t }}</h4>
<ul class="rvt-pagination rvt-justify-center js-pager__items">
{# Print first item if we are not on the first page. #}
{% if items.first %}
<li class="rvt-pagination__item rvt-pagination__item--first">
<a href="{{ items.first.href }}" title="{{ 'Go to first page'|t }}"{{ items.first.attributes|without('href', 'title') }}>
{% else %}
<li class="rvt-pagination__item rvt-pagination__item--first" aria-label="No first page">
{% endif %}
<span class="rvt-sr-only">{{ 'First page'|t }}</span>
<svg fill="currentColor" width="16" height="16" viewBox="0 0 16 16"><path d="M.586 8 7 14.414 8.414 13l-5-5 5-5L7 1.586.586 8Z"></path><path d="M6.586 8 13 14.414 14.414 13l-5-5 5-5L13 1.586 6.586 8Z"></path></svg>
<span aria-hidden="true">{{ items.first.text|default('')|replace(replacements) }}</span>
{% if items.first %}</a>{% endif %}
</li>
{# Print previous item if we are not on the first page. #}
{% if items.previous %}
<li class="rvt-pagination__item rvt-pagination__item--previous">
<a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel') }}>
{% else %}
<li class="rvt-pagination__item rvt-pagination__item--previous" aria-label="No previous page">
{% endif %}
<span class="rvt-sr-only">{{ 'Previous page'|t }}</span>
<svg fill="currentColor" width="16" height="16" viewBox="0 0 16 16"><path d="M9.737.854 3.69 8l6.047 7.146 1.526-1.292L6.31 8l4.953-5.854L9.737.854Z"></path></svg>
<span aria-hidden="true">{{ items.previous.text|default('')|replace(replacements) }}</span>
{% if items.previous %}</a>{% endif %}
</li>
{# Add an ellipsis if there are further previous pages. #}
{% if ellipses.previous %}
<li class="rvt-pagination__item rvt-pagination__item--ellipsis" role="presentation">…</li>
{% endif %}
{# Now generate the actual pager piece. #}
{% for key, item in items.pages %}
<li class="rvt-pagination__item{{ current == key ? ' is-active' : '' }}">
{% if current == key %}
{% set title = 'Current page'|t %}
{% else %}
{% set title = 'Go to page @key'|t({'@key': key}) %}
{% endif %}
<a href="{{ item.href }}" title="{{ title }}"{{ current == key ? ' aria-current="page"'}}{{ item.attributes|without('href', 'title', 'aria-current') }}>
<span class="rvt-sr-only">
{{ current == key ? 'Current page'|t : 'Page'|t }}
</span>
{{- key -}}
</a>
</li>
{% endfor %}
{# Add an ellipsis if there are further next pages. #}
{% if ellipses.next %}
<li class="rvt-pagination__item rvt-pagination__item--ellipsis" role="presentation">…</li>
{% endif %}
{# Print next item if we are not on the last page. #}
{% if items.next %}
<li class="rvt-pagination__item rvt-pagination__item--next">
<a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel') }}>
{% else %}
<li class="rvt-pagination__item rvt-pagination__item--next" aria-label="No next page">
{% endif %}
<span class="rvt-sr-only">{{ 'Next page'|t }}</span>
<span aria-hidden="true">{{ items.next.text|default('')|replace(replacements) }}</span>
<svg fill="currentColor" width="16" height="16" viewBox="0 0 16 16"><path d="M6.263 15.146 12.31 8 6.263.854 4.737 2.146 9.69 8l-4.953 5.854 1.526 1.292Z"></path></svg>
{% if items.next %}</a>{% endif %}
</li>
{# Print last item if we are not on the last page. #}
{% if items.last %}
<li class="rvt-pagination__item rvt-pagination__item--last">
<a href="{{ items.last.href }}" title="{{ 'Go to last page'|t }}"{{ items.last.attributes|without('href', 'title') }}>
{% else %}
<li class="rvt-pagination__item rvt-pagination__item--last" aria-label="No last page">
{% endif %}
<span class="rvt-sr-only">{{ 'Last page'|t }}</span>
<span aria-hidden="true">{{ items.last.text|default('')|replace(replacements) }}</span>
<svg fill="currentColor" width="16" height="16" viewBox="0 0 16 16"><path d="M9.414 8 3 1.586 1.586 3l5 5-5 5L3 14.414 9.414 8Z"></path><path d="M15.414 8 9 1.586 7.586 3l5 5-5 5L9 14.414 15.414 8Z"></path></svg>
{% if items.last %}</a>{% endif %}
</li>
</ul>
</nav>
{% endif %}
