e65b599a47d1db9651d5c9ffd2bfb7951c2c0d55
[yaffs-website] / web / themes / contrib / bootstrap / templates / system / 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  * @ingroup templates
30  *
31  * @see template_preprocess_pager()
32  */
33 #}
34 {% if items %}
35   <nav class="pager-nav text-center" role="navigation" aria-labelledby="pagination-heading">
36     <h4 id="pagination-heading" class="visually-hidden">{{ 'Pagination'|t }}</h4>
37     <ul class="pagination js-pager__items">
38
39       {# Print first item if we are not on the first page. #}
40       {% if items.first %}
41         <li class="pager__item pager__item--first">
42           <a href="{{ items.first.href }}" title="{{ 'Go to first page'|t }}" rel="prev"{{ items.first.attributes }}>
43             <span class="visually-hidden">{{ 'First page'|t }}</span>
44             <span aria-hidden="true">{{ items.first.text|default('first'|t) }}</span>
45           </a>
46         </li>
47       {% endif %}
48
49       {# Print previous item if we are not on the first page. #}
50       {% if items.previous %}
51         <li class="pager__item pager__item--previous">
52           <a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes }}>
53             <span class="visually-hidden">{{ 'Previous page'|t }}</span>
54             <span aria-hidden="true">{{ items.previous.text|default('previous'|t) }}</span>
55           </a>
56         </li>
57       {% endif %}
58
59       {# Now generate the actual pager piece. #}
60       {% for key, item in items.pages %}
61         <li class="pager__item{{ current == key ? ' is-active active' : '' }}">
62           {% if current == key %}
63             {% set title = 'Current page'|t %}
64           {% else %}
65             {% set title = 'Go to page @key'|t({'@key': key}) %}
66           {% endif %}
67           <a href="{{ item.href }}" title="{{ title }}"{{ item.attributes }}>
68             <span class="visually-hidden">
69               {{ current == key ? 'Current page'|t : 'Page'|t }}
70             </span>
71             {{- key -}}
72           </a>
73         </li>
74       {% endfor %}
75
76       {# Print next item if we are not on the last page. #}
77       {% if items.next %}
78         <li class="pager__item pager__item--next">
79           <a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes }}>
80             <span class="visually-hidden">{{ 'Next page'|t }}</span>
81             <span aria-hidden="true">{{ items.next.text|default('next'|t) }}</span>
82           </a>
83         </li>
84       {% endif %}
85
86       {# Print last item if we are not on the last page. #}
87       {% if items.last %}
88       <li class="pager__item pager__item--last">
89         <a href="{{ items.last.href }}" title="{{ 'Go to last page'|t }}" rel="last"{{ items.last.attributes }}>
90           <span class="visually-hidden">{{ 'Last page'|t }}</span>
91           <span aria-hidden="true">{{ items.last.text|default('last'|t) }}</span>
92         </a>
93       </li>
94       {% endif %}
95
96     </ul>
97   </nav>
98 {% endif %}