Chris@0
|
1 {#
|
Chris@0
|
2 /**
|
Chris@0
|
3 * @file
|
Chris@0
|
4 * Theme override to display a pager.
|
Chris@0
|
5 *
|
Chris@0
|
6 * Available variables:
|
Chris@18
|
7 * - heading_id: Pagination heading ID.
|
Chris@0
|
8 * - items: List of pager items.
|
Chris@0
|
9 * The list is keyed by the following elements:
|
Chris@0
|
10 * - first: Item for the first page; not present on the first page of results.
|
Chris@0
|
11 * - previous: Item for the previous page; not present on the first page
|
Chris@0
|
12 * of results.
|
Chris@0
|
13 * - next: Item for the next page; not present on the last page of results.
|
Chris@0
|
14 * - last: Item for the last page; not present on the last page of results.
|
Chris@0
|
15 * - pages: List of pages, keyed by page number.
|
Chris@0
|
16 * Sub-sub elements:
|
Chris@0
|
17 * items.first, items.previous, items.next, items.last, and each item inside
|
Chris@0
|
18 * items.pages contain the following elements:
|
Chris@0
|
19 * - href: URL with appropriate query parameters for the item.
|
Chris@0
|
20 * - attributes: A keyed list of HTML attributes for the item.
|
Chris@0
|
21 * - text: The visible text used for the item link, such as "‹ Previous"
|
Chris@0
|
22 * or "Next ›".
|
Chris@0
|
23 * - current: The page number of the current page.
|
Chris@0
|
24 * - ellipses: If there are more pages than the quantity allows, then an
|
Chris@0
|
25 * ellipsis before or after the listed pages may be present.
|
Chris@0
|
26 * - previous: Present if the currently visible list of pages does not start
|
Chris@0
|
27 * at the first page.
|
Chris@0
|
28 * - next: Present if the visible list of pages ends before the last page.
|
Chris@0
|
29 *
|
Chris@0
|
30 * @see template_preprocess_pager()
|
Chris@0
|
31 */
|
Chris@0
|
32 #}
|
Chris@0
|
33 {% if items %}
|
Chris@18
|
34 <nav class="pager" role="navigation" aria-labelledby="{{ heading_id }}">
|
Chris@18
|
35 <h4 id="{{ heading_id }}" class="visually-hidden">{{ 'Pagination'|t }}</h4>
|
Chris@0
|
36 <ul class="pager__items js-pager__items">
|
Chris@0
|
37 {# Print first item if we are not on the first page. #}
|
Chris@0
|
38 {% if items.first %}
|
Chris@0
|
39 <li class="pager__item pager__item--first">
|
Chris@0
|
40 <a href="{{ items.first.href }}" title="{{ 'Go to first page'|t }}"{{ items.first.attributes|without('href', 'title') }}>
|
Chris@0
|
41 <span class="visually-hidden">{{ 'First page'|t }}</span>
|
Chris@0
|
42 <span aria-hidden="true">{{ items.first.text|default('« First'|t) }}</span>
|
Chris@0
|
43 </a>
|
Chris@0
|
44 </li>
|
Chris@0
|
45 {% endif %}
|
Chris@0
|
46 {# Print previous item if we are not on the first page. #}
|
Chris@0
|
47 {% if items.previous %}
|
Chris@0
|
48 <li class="pager__item pager__item--previous">
|
Chris@0
|
49 <a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel') }}>
|
Chris@0
|
50 <span class="visually-hidden">{{ 'Previous page'|t }}</span>
|
Chris@0
|
51 <span aria-hidden="true">{{ items.previous.text|default('‹ Previous'|t) }}</span>
|
Chris@0
|
52 </a>
|
Chris@0
|
53 </li>
|
Chris@0
|
54 {% endif %}
|
Chris@0
|
55 {# Add an ellipsis if there are further previous pages. #}
|
Chris@0
|
56 {% if ellipses.previous %}
|
Chris@0
|
57 <li class="pager__item pager__item--ellipsis" role="presentation">…</li>
|
Chris@0
|
58 {% endif %}
|
Chris@0
|
59 {# Now generate the actual pager piece. #}
|
Chris@0
|
60 {% for key, item in items.pages %}
|
Chris@0
|
61 <li class="pager__item{{ current == key ? ' is-active' : '' }}">
|
Chris@0
|
62 {% if current == key %}
|
Chris@0
|
63 {% set title = 'Current page'|t %}
|
Chris@0
|
64 {% else %}
|
Chris@0
|
65 {% set title = 'Go to page @key'|t({'@key': key}) %}
|
Chris@0
|
66 {% endif %}
|
Chris@0
|
67 <a href="{{ item.href }}" title="{{ title }}"{{ item.attributes|without('href', 'title') }}>
|
Chris@0
|
68 <span class="visually-hidden">
|
Chris@0
|
69 {{ current == key ? 'Current page'|t : 'Page'|t }}
|
Chris@0
|
70 </span>
|
Chris@0
|
71 {{- key -}}
|
Chris@0
|
72 </a>
|
Chris@0
|
73 </li>
|
Chris@0
|
74 {% endfor %}
|
Chris@0
|
75 {# Add an ellipsis if there are further next pages. #}
|
Chris@0
|
76 {% if ellipses.next %}
|
Chris@0
|
77 <li class="pager__item pager__item--ellipsis" role="presentation">…</li>
|
Chris@0
|
78 {% endif %}
|
Chris@0
|
79 {# Print next item if we are not on the last page. #}
|
Chris@0
|
80 {% if items.next %}
|
Chris@0
|
81 <li class="pager__item pager__item--next">
|
Chris@0
|
82 <a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel') }}>
|
Chris@0
|
83 <span class="visually-hidden">{{ 'Next page'|t }}</span>
|
Chris@0
|
84 <span aria-hidden="true">{{ items.next.text|default('Next ›'|t) }}</span>
|
Chris@0
|
85 </a>
|
Chris@0
|
86 </li>
|
Chris@0
|
87 {% endif %}
|
Chris@0
|
88 {# Print last item if we are not on the last page. #}
|
Chris@0
|
89 {% if items.last %}
|
Chris@0
|
90 <li class="pager__item pager__item--last">
|
Chris@0
|
91 <a href="{{ items.last.href }}" title="{{ 'Go to last page'|t }}"{{ items.last.attributes|without('href', 'title') }}>
|
Chris@0
|
92 <span class="visually-hidden">{{ 'Last page'|t }}</span>
|
Chris@0
|
93 <span aria-hidden="true">{{ items.last.text|default('Last »'|t) }}</span>
|
Chris@0
|
94 </a>
|
Chris@0
|
95 </li>
|
Chris@0
|
96 {% endif %}
|
Chris@0
|
97 </ul>
|
Chris@0
|
98 </nav>
|
Chris@0
|
99 {% endif %}
|