annotate core/modules/system/templates/pager.html.twig @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents af1871eacc83
children
rev   line source
Chris@0 1 {#
Chris@0 2 /**
Chris@0 3 * @file
Chris@0 4 * Default theme implementation 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 * @ingroup themeable
Chris@0 33 */
Chris@0 34 #}
Chris@0 35 {% if items %}
Chris@18 36 <nav class="pager" role="navigation" aria-labelledby="{{ heading_id }}">
Chris@18 37 <h4 id="{{ heading_id }}" class="visually-hidden">{{ 'Pagination'|t }}</h4>
Chris@0 38 <ul class="pager__items js-pager__items">
Chris@0 39 {# Print first item if we are not on the first page. #}
Chris@0 40 {% if items.first %}
Chris@0 41 <li class="pager__item pager__item--first">
Chris@0 42 <a href="{{ items.first.href }}" title="{{ 'Go to first page'|t }}"{{ items.first.attributes|without('href', 'title') }}>
Chris@0 43 <span class="visually-hidden">{{ 'First page'|t }}</span>
Chris@0 44 <span aria-hidden="true">{{ items.first.text|default('« First'|t) }}</span>
Chris@0 45 </a>
Chris@0 46 </li>
Chris@0 47 {% endif %}
Chris@0 48 {# Print previous item if we are not on the first page. #}
Chris@0 49 {% if items.previous %}
Chris@0 50 <li class="pager__item pager__item--previous">
Chris@0 51 <a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel') }}>
Chris@0 52 <span class="visually-hidden">{{ 'Previous page'|t }}</span>
Chris@0 53 <span aria-hidden="true">{{ items.previous.text|default('‹ Previous'|t) }}</span>
Chris@0 54 </a>
Chris@0 55 </li>
Chris@0 56 {% endif %}
Chris@0 57 {# Add an ellipsis if there are further previous pages. #}
Chris@0 58 {% if ellipses.previous %}
Chris@0 59 <li class="pager__item pager__item--ellipsis" role="presentation">&hellip;</li>
Chris@0 60 {% endif %}
Chris@0 61 {# Now generate the actual pager piece. #}
Chris@0 62 {% for key, item in items.pages %}
Chris@0 63 <li class="pager__item{{ current == key ? ' is-active' : '' }}">
Chris@0 64 {% if current == key %}
Chris@0 65 {% set title = 'Current page'|t %}
Chris@0 66 {% else %}
Chris@0 67 {% set title = 'Go to page @key'|t({'@key': key}) %}
Chris@0 68 {% endif %}
Chris@0 69 <a href="{{ item.href }}" title="{{ title }}"{{ item.attributes|without('href', 'title') }}>
Chris@0 70 <span class="visually-hidden">
Chris@0 71 {{ current == key ? 'Current page'|t : 'Page'|t }}
Chris@0 72 </span>
Chris@0 73 {{- key -}}
Chris@0 74 </a>
Chris@0 75 </li>
Chris@0 76 {% endfor %}
Chris@0 77 {# Add an ellipsis if there are further next pages. #}
Chris@0 78 {% if ellipses.next %}
Chris@0 79 <li class="pager__item pager__item--ellipsis" role="presentation">&hellip;</li>
Chris@0 80 {% endif %}
Chris@0 81 {# Print next item if we are not on the last page. #}
Chris@0 82 {% if items.next %}
Chris@0 83 <li class="pager__item pager__item--next">
Chris@0 84 <a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel') }}>
Chris@0 85 <span class="visually-hidden">{{ 'Next page'|t }}</span>
Chris@0 86 <span aria-hidden="true">{{ items.next.text|default('Next ›'|t) }}</span>
Chris@0 87 </a>
Chris@0 88 </li>
Chris@0 89 {% endif %}
Chris@0 90 {# Print last item if we are not on the last page. #}
Chris@0 91 {% if items.last %}
Chris@0 92 <li class="pager__item pager__item--last">
Chris@0 93 <a href="{{ items.last.href }}" title="{{ 'Go to last page'|t }}"{{ items.last.attributes|without('href', 'title') }}>
Chris@0 94 <span class="visually-hidden">{{ 'Last page'|t }}</span>
Chris@0 95 <span aria-hidden="true">{{ items.last.text|default('Last »'|t) }}</span>
Chris@0 96 </a>
Chris@0 97 </li>
Chris@0 98 {% endif %}
Chris@0 99 </ul>
Chris@0 100 </nav>
Chris@0 101 {% endif %}