app/template/default/Block/category_nav_sp.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. {% set Categories = repository('Eccube\\Entity\\Category').getList() %}
  9. {% block javascript %}
  10.     <script>
  11.         $(function() {
  12.             $('.ec-headerCategoryArea .ec-itemNav__nav li > a').on('click', function() {
  13.                 $categoryItem = $(this).parent('.haschild');
  14.                 $categoryList = $categoryItem.children('.category_child');
  15.                 $childrenIcon = $(this).children('.only-opend');
  16.                 if ($categoryList.length > 0){
  17.                     if ($categoryList.css('display') == 'none') {
  18.                         $categoryList.slideDown(300);
  19.                         $childrenIcon.addClass('active');
  20.                     } else {
  21.                         $categoryList.slideUp(250);
  22.                         $childrenIcon.removeClass('active');
  23.                     }
  24.                     return false;
  25.                 }
  26.             });
  27.         });
  28.     </script>
  29. {% endblock %}
  30. {% macro tree(Category) %}
  31.     {% from _self import tree %}
  32.     <a href="{{ url('product_list') }}?category_id={{ Category.id }}#tab-link">
  33.         {{ Category.name }}
  34.         {% if Category.children|length == 0 %}
  35.             <img src="{{ asset('assets/icon/icon_arrow_red.svg') }}" class="ec-itemNav__iconlink" alt="矢印アイコン">
  36.         {% else %}
  37.             <img src="{{ asset('assets/icon/icon_add.svg') }}" class="ec-itemNav__iconlink only-opend" alt="プラスアイコン">
  38.             <img src="{{ asset('assets/icon/icon_minus.svg') }}" class="ec-itemNav__iconlink" alt="マイナスアイコン">
  39.         {% endif %}
  40.     </a>
  41.     {% if Category.children|length > 0 %}
  42.         <ul style="display: none;" class="category_child">
  43.             <li>
  44.                 <a href="{{ url('product_list') }}?category_id={{ Category.id }}">
  45.                     <span>すべて</span>
  46.                     <img src="{{ asset('assets/icon/icon_arrow_red.svg') }}" class="ec-itemNav__iconlink" alt="矢印アイコン">
  47.                 </a>
  48.             </li>
  49.             {% for ChildCategory in Category.children %}
  50.                 <li>
  51.                     {{ tree(ChildCategory) }}
  52.                 </li>
  53.             {% endfor %}
  54.         </ul>
  55.     {% endif %}
  56. {% endmacro %}
  57. {# @see https://github.com/bolt/bolt/pull/2388 #}
  58. {% from _self import tree %}
  59. <div class="ec-headerCategoryArea">
  60.     <div class="ec-headerCategoryArea__heading">
  61.         <p>{{ 'カテゴリから探す'|trans }}</p>
  62.         <span class="ec-headerCategoryArea__toggle">すべて開く</span>
  63.     </div>
  64.     <div class="ec-itemNav">
  65.         <ul class="ec-itemNav__nav">
  66.             {% for Category in Categories %}
  67.                 <li>
  68.                     {{ tree(Category) }}
  69.                 </li>
  70.             {% endfor %}
  71.         </ul>
  72.     </div>
  73. </div>