Commit ffe1494f authored by Ivica Puljic's avatar Ivica Puljic Committed by Ivica Puljic
Browse files

Issue #3300955 by pivica: Add twig blocks to pager template for easier html modification

parent 21482241
Loading
Loading
Loading
Loading
+49 −35
Original line number Diff line number Diff line
@@ -40,15 +40,18 @@
    <ul class="pagination js-pager__items">
      {# Print first item if we are not on the first page. #}
      {% if items.first %}
        {% block items_first %}
          <li class="page-item page-item--first">
            <a class="{{ page_link_classes }}" href="{{ items.first.href }}"{{ items.first.attributes|without('href') }}>
              <span class="visually-hidden">{{ 'First page'|t }}</span>
              <span aria-hidden="true">{{ items.first.text|default('« First'|t) }}</span>
            </a>
          </li>
        {% endblock %}
      {% endif %}
      {# Print previous item if we are not on the first page. #}
      {% if items.previous %}
        {% block items_previous %}
          <li class="page-item page-item--previous">
            {# There is no such thing as items.previous.attributes for now.
               However classy is rendering it so we will do it also. #}
@@ -57,25 +60,33 @@
              <span aria-hidden="true">{{ items.previous.text|default('‹ Previous'|t) }}</span>
            </a>
          </li>
        {% endblock %}
      {% endif %}
      {# Add an ellipsis if there are further previous pages. #}
      {% if ellipses.previous %}
        {% block elipses_previous %}
          <li class="page-item page-item--ellipsis"><span class="{{ page_link_ellipses_classes }}">&hellip;</span></li>
        {% endblock %}
      {% endif %}
      {# Now generate the actual pager piece. #}
      {% for key, item in items.pages %}
        {% block items_pages %}
          <li class="page-item{{ current == key ? ' active' : '' }}">
            <a class="{{ current == key ? page_link_active_classes : page_link_classes }}" href="{{ item.href }}"{{ item.attributes|without('href') }}>
              {{ key }}
            </a>
          </li>
        {% endblock %}
      {% endfor %}
      {# Add an ellipsis if there are further next pages. #}
      {% if ellipses.next %}
        {% block elipses_next %}
          <li class="page-item page-item--ellipsis"><span class="{{ page_link_ellipses_classes }}">&hellip;</span></li>
        {% endblock %}
      {% endif %}
      {# Print next item if we are not on the last page. #}
      {% if items.next %}
        {% block items_next %}
          <li class="page-item page-item--next">
            {# There is no such thing as items.next.attributes for now.
               However classy is rendering it so we will do it also. #}
@@ -84,15 +95,18 @@
              <span aria-hidden="true">{{ items.next.text|default('Next ›'|t) }}</span>
            </a>
          </li>
        {% endblock %}
      {% endif %}
      {# Print last item if we are not on the last page. #}
      {% if items.last %}
        {% block items_last %}
          <li class="page-item page-item--last">
            <a class="{{ page_link_classes }}" href="{{ items.last.href }}"{{ items.last.attributes|without('href') }}>
              <span class="visually-hidden">{{ 'Last page'|t }}</span>
              <span aria-hidden="true">{{ items.last.text|default('Last »'|t) }}</span>
            </a>
          </li>
        {% endblock %}
      {% endif %}
    </ul>
  </nav>
+29 −23
Original line number Diff line number Diff line
@@ -16,15 +16,18 @@
     added in views template is lost. So we will add it here again.#}
  <nav {{ attributes.addClass('views__pager') }} aria-label="{{ 'Pagination'|t }}">
    <ul class="pagination js-pager__items">
      {% if items.previous %}
      {% if items.previous -%}
        {% block items_previous %}
          <li class="page-item">
            <a class="page-link" href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel') }}>
              <span class="visually-hidden">{{ 'Previous page'|t }}</span>
              <span aria-hidden="true">{{ items.previous.text|default('‹‹'|t) }}</span>
            </a>
          </li>
      {% endif %}
      {% if items.current %}
        {% endblock %}
      {%- endif %}
      {% if items.current -%}
        {% block items_current %}
          <li class="page-item disabled">
            <span class="page-link">
              {% trans %}
@@ -32,14 +35,17 @@
              {% endtrans %}
            </span>
          </li>
      {% endif %}
        {% endblock %}
      {%- endif %}
      {% if items.next %}
        {% block items_next %}
          <li class="page-item">
            <a class="page-link" href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel') }}>
              <span class="visually-hidden">{{ 'Next page'|t }}</span>
              <span aria-hidden="true">{{ items.next.text|default('››'|t) }}</span>
            </a>
          </li>
        {% endblock %}
      {% endif %}
    </ul>
  </nav>