app/template/bravers/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. {% macro tree(Category) %}
  9.     {% from _self import tree %}
  10.     <a href="{{ url('product_list') }}?category_id={{ Category.id }}">
  11.         <span>{{ Category.name }}</span>
  12.         {% if Category.children|length > 0 %}
  13.             <img src="{{ asset('assets/img/common/ic_plus.svg') }}" alt="お気に入り" width="12" height="12" loading="lazy">
  14.         {% else %}
  15.             <img src="{{ asset('assets/img/common/ic_chervon_right.svg') }}" alt="お気に入り" width="6" height="9" loading="lazy">
  16.         {% endif %}
  17.     </a>
  18.     {% if Category.children|length > 0 %}
  19.         <ul>
  20.             {% for ChildCategory in Category.children %}
  21.                 <li>
  22.                     {{ tree(ChildCategory) }}
  23.                 </li>
  24.             {% endfor %}
  25.         </ul>
  26.     {% endif %}
  27. {% endmacro %}
  28. {# @see https://github.com/bolt/bolt/pull/2388 #}
  29. {% from _self import tree %}
  30. <script>
  31.     $(document).ready(function() {
  32.         $(".ec-drawerRole .ec-headerCategoryArea .ec-itemNav__nav li ul li a, .ec-drawerRole .ec-headerCategoryArea .ec-itemNav__nav li a").on("click", function(e) {
  33.             $(this).toggleClass("active");
  34.             if($(this).hasClass("active")) {
  35.                 $(this).find(".ic_plus").addClass("d-none");
  36.                 $(this).find(".ic_minus").removeClass("d-none");
  37.                 $(this).closest("li").find("ul").removeClass("d-none");
  38.             } else {
  39.                 $(this).find(".ic_plus").removeClass("d-none");
  40.                 $(this).find(".ic_minus").addClass("d-none");
  41.                 $(this).closest("li").find("ul").addClass("d-none");
  42.             }
  43.         })
  44.     })
  45. </script>
  46. <div class="ec-headerCategoryArea">
  47.     <div class="ec-headerCategoryArea__heading">
  48.         <p>{{ '商品カテゴリーから探す'|trans }}</p>
  49.     </div>
  50.     <div class="ec-itemNav">
  51.         <ul class="ec-itemNav__nav">
  52.             {% for Category in TopCategories %}
  53.                 <li>
  54.                     {% if Category.id == constant('Customize\\Common\\Constant::DEFAULT_CATEGORY_ID') or Category.id == constant('Customize\\Common\\Constant::MANUFACTURER_CATEGORY_ID') %}
  55.                         <a href="javascript:void(0)">
  56.                             <span>{{ Category.name }}</span>
  57.                             <img class="ic_plus" src="{{ asset('assets/img/common/ic_plus.svg') }}" alt="お気に入り" width="12" height="12" loading="lazy">
  58.                             <img class="ic_minus d-none" src="{{ asset('assets/img/common/ic_minus.svg') }}" alt="お気に入り" width="12" height="12" loading="lazy">
  59.                         </a>
  60.                         {% if Category.children|length > 0 %}
  61.                             <ul>
  62.                                 {% for ChildCategory in Category.children %}
  63.                                     <li>
  64.                                         {{ tree(ChildCategory) }}
  65.                                     </li>
  66.                                 {% endfor %}
  67.                             </ul>
  68.                         {% endif %}
  69.                     {% endif %}
  70.                 </li>
  71.             {% endfor %}
  72.         </ul>
  73.     </div>
  74. </div>