louie-8.x-1.x-dev/templates/navigation/pager.html.twig

templates/navigation/pager.html.twig
{# @Component
name: Pager
description: Theme override to display a pager.
group: Drupal>Misc
samples:
  Mini:
    items:
      previous: {href: '#'}
      next: {href: '#'}
  Extended:
    current: 2
    items:
      first: {href: '#'}
      previous: {href: '#'}
      pages:
        1: {href: '#'}
        2: {href: '#'}
        3: {href: '#'}
        4: {href: '#'}
      next: {href: '#'}
      last: {href: '#'}
#}

{#
/**
 * @file
 * Theme override to display a pager.
 *
 * Available variables:
 * - items: List of pager items.
 *   The list is keyed by the following elements:
 *   - first: Item for the first page; not present on the first page of results.
 *   - previous: Item for the previous page; not present on the first page
 *     of results.
 *   - next: Item for the next page; not present on the last page of results.
 *   - last: Item for the last page; not present on the last page of results.
 *   - pages: List of pages, keyed by page number.
 *   Sub-sub elements:
 *   items.first, items.previous, items.next, items.last, and each item inside
 *   items.pages contain the following elements:
 *   - href: URL with appropriate query parameters for the item.
 *   - attributes: A keyed list of HTML attributes for the item.
 *   - text: The visible text used for the item link, such as "‹ Previous"
 *     or "Next ›".
 * - current: The page number of the current page.
 * - ellipses: If there are more pages than the quantity allows, then an
 *   ellipsis before or after the listed pages may be present.
 *   - previous: Present if the currently visible list of pages does not start
 *     at the first page.
 *   - next: Present if the visible list of pages ends before the last page.
 *
 * @see template_preprocess_pager()
 */
#}

{#
  Foundation 6 style pager.
  http://foundation.zurb.com/sites/docs/pagination.html

  Required:
    CSS:  enable "@include foundation-pagination" in /themes/custom/torsion/css/src/style.scss
#}
{% if items %}
  <nav role="navigation" aria-labelledby="pagination-heading">
    <h4 id="pagination-heading" class="visually-hidden">{{ 'Pagination'|t }}</h4>
    <ul class="pagination text-center" role="navigation" aria-label="Pagination">
      {# Print previous item if we are not on the first page. #}
      {% if items.previous %}
        <li class="pagination-previous"><a href="{{ items.previous.href }}" aria-label="Previous page">Previous</a></li>
      {% else %}
        <li class="pagination-previous disabled">Previous</li>
      {% endif %}
      {# Add an ellipsis if there are further previous pages. #}
      {% if ellipses.previous %}
        <li class="ellipsis" role="presentation"></li>
      {% endif %}
      {# Now generate the actual pager piece. #}
      {% for key, item in items.pages %}
        <li class="{{ current == key ? ' current' : '' }}">
          {% if current == key %}
            {% set title = 'Current page'|t %}
          {% else %}
            {% set title = 'Go to page @key'|t({'@key': key}) %}
          {% endif %}
          {% if current == key %}
            <span class="show-for-sr">You're on page</span> {{- key -}}
          {% else %}
            <a href="{{ item.href }}" aria-label="{{ title }}" title="{{ title }}">
              {{- key -}}
            </a>
          {% endif %}
        </li>
      {% endfor %}
      {# Add an ellipsis if there are further next pages. #}
      {% if ellipses.next %}
        <li class="ellipsis" role="presentation"></li>
      {% endif %}
      {# Print next item if we are not on the last page. #}
      {% if items.next %}
        <li class="pagination-next"><a href="#" aria-label="Next page">Next</a></li>
      {% else %}
        <li class="pagination-next disabled">Next</li>
      {% endif %}
    </ul>
  </nav>
{% endif %}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc