annotate core/modules/system/templates/pager.html.twig @ 0:4c8ae668cc8c

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