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