src/Eccube/Resource/template/default/pager.twig line 1

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  4. http://www.ec-cube.co.jp/
  5. For the full copyright and license information, please view the LICENSE
  6. file that was distributed with this source code.
  7. #}
  8. {% if pages.pageCount > 1 %}
  9.     <ul class="ec-pager">
  10.         {% set route_name = route_name is defined ? route_name : app.request.attributes.get('_route') %}
  11.         {% if route_name is defined and route_name != app.request.attributes.get('_route') %}
  12.             {# 明示的にルート名が指定されている場合(ブロックから呼ばれた場合など)、base_paramsを空にする #}
  13.             {% set base_params = {} %}
  14.         {% else %}
  15.             {# 現在のルートを使用する場合、現在のリクエストからパラメータを取得 #}
  16.             {% set base_params = app.request.attributes.get('_route_params') is iterable ? app.request.attributes.get('_route_params') : {} %}
  17.             {% set base_params = base_params|merge(app.request.query.all) %}
  18.         {% endif %}
  19.         {# 最初へ #}
  20.         {% if pages.firstPageInRange != 1 %}
  21.             <li class="ec-pager__item">
  22.                 <a href="{{ path(route_name, base_params|merge({'pageno': pages.first})) }}">{{ '最初へ'|trans }}</a></li>
  23.         {% endif %}
  24.         {# 前へ #}
  25.         {% if pages.previous is defined %}
  26.             <li class="ec-pager__item">
  27.                 <a href="{{ path(route_name, base_params|merge({'pageno': pages.previous})) }}">{{ '前へ'|trans }}</a></li>
  28.         {% endif %}
  29.         {# 1ページリンクが表示されない場合、「...」を表示 #}
  30.         {% if pages.firstPageInRange != 1 %}
  31.             <li class="ec-pager__item">...</li>
  32.         {% endif %}
  33.         {% for page in pages.pagesInRange %}
  34.             {% if page == pages.current %}
  35.                 <li class="ec-pager__item--active"><a href="{{ path(route_name, base_params|merge({'pageno': page})) }}"> {{ page }} </a></li>
  36.             {% else %}
  37.                 <li class="ec-pager__item"><a href="{{ path(route_name, base_params|merge({'pageno': page})) }}"> {{ page }} </a></li>
  38.             {% endif %}
  39.         {% endfor %}
  40.         {# 最終ページリンクが表示されない場合、「...」を表示 #}
  41.         {% if pages.last != pages.lastPageInRange %}
  42.             <li class="ec-pager__item">...</li>
  43.         {% endif %}
  44.         {# 次へ #}
  45.         {% if pages.next is defined %}
  46.             <li class="ec-pager__item">
  47.                 <a href="{{ path(route_name, base_params|merge({'pageno': pages.next})) }}">{{ '次へ'|trans }}</a></li>
  48.         {% endif %}
  49.         {# 最後へ #}
  50.         {% if pages.last != pages.lastPageInRange %}
  51.             <li class="ec-pager__item">
  52.                 <a href="{{ path(route_name, base_params|merge({'pageno': pages.last})) }}">{{ '最後へ'|trans }}</a></li>
  53.         {% endif %}
  54.     </ul>
  55. {% endif %}