app/template/ibn4203/Block/customize_category_side.twig line 1

Open in your IDE?
  1. {% if app.request.get('vendor_id') %}
  2.     {% set Categories = repository('Eccube\\Entity\\Category').findByVendorId(app.request.get('vendor_id')) %}
  3. {% else %}
  4.     {# {% set Categories = repository('Eccube\\Entity\\Category').getList() %} #}
  5.     {% set Categories = repository('Eccube\\Entity\\Category').findByVendor(app.user) %}
  6. {% endif %}
  7. {% macro tree(Category) %}
  8.     {% from _self import tree %}
  9.     {% if app.request.pathInfo == '/products/list_vendor' %}
  10.         <div class="customize_category_label">
  11.             <a class="page_link2" href="{{ url('product_list_vendor') }}?category_id={{ Category.id }}&vendor_id={{ app.request.get('vendor_id') }}">{{ Category.name }}</a>
  12.             {% if Category.children|length > 0 %}
  13.             <i class="fa-solid fa-chevron-right toggle_icon py-2 px-5"></i>
  14.             {% endif %}
  15.         </div>
  16.         {% if Category.children|length > 0 %}
  17.         <ul class="customize_category_accordion">
  18.             {% for ChildCategory in Category.children %}
  19.                 <li>
  20.                     {{ tree(ChildCategory) }}
  21.                 </li>
  22.             {% endfor %}
  23.         </ul>
  24.         {% endif %}
  25.     {% else %}
  26.         <div class="customize_category_label">
  27.             <a class="page_link2" href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a>
  28.             {% if Category.children|length > 0 %}
  29.             <i class="fa-solid fa-chevron-right toggle_icon py-2 px-5"></i>
  30.             {% endif %}
  31.         </div>
  32.         {% if Category.children|length > 0 %}
  33.         <ul class="customize_category_accordion">
  34.             {% for ChildCategory in Category.children %}
  35.                 <li>
  36.                     {{ tree(ChildCategory) }}
  37.                 </li>
  38.             {% endfor %}
  39.         </ul>
  40.         {% endif %}
  41.     {% endif %}
  42. {% endmacro %}
  43. <script>
  44. $(document).ready(function () {
  45.     $('.customize_category_side_area').on('click', '.toggle_icon', function (e) {
  46.         const icon = $(this);
  47.         const submenu = icon.closest('.customize_category_label').next('.customize_category_accordion');
  48.         if (submenu.length) {
  49.             submenu.slideToggle();
  50.             // アイコン切り替え
  51.             icon.toggleClass('fa-chevron-right fa-chevron-down');
  52.         }
  53.     });
  54. });
  55. </script>
  56. {% from _self import tree %}
  57. <div class="customize_category_side_area">
  58.     <p class="customize_category_side_title">カテゴリーから探す</p>
  59.     <ul>
  60.         {% for Category in Categories %}
  61.             <li class="customize_category_block">
  62.                 {{ tree(Category) }}
  63.             </li>
  64.         {% endfor %}
  65.     </ul>
  66.     <hr>
  67. </div>