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. {% macro tree(Category) %}
  10.     {% from _self import tree %}
  11.     <a href="{{ url('product_list') }}?category_id={{ Category.id }}">
  12.         {{ Category.name }}
  13.     </a>
  14.     {% if Category.children|length > 0 %}
  15.         <ul>
  16.             {% for ChildCategory in Category.children %}
  17.                 <li>
  18.                     {{ tree(ChildCategory) }}
  19.                 </li>
  20.             {% endfor %}
  21.         </ul>
  22.     {% endif %}
  23. {% endmacro %}
  24. {# @see https://github.com/bolt/bolt/pull/2388 #}
  25. {% from _self import tree %}
  26. <div class="ec-headerCategoryArea">
  27.     <div class="ec-headerCategoryArea__heading js-toggle-category" style="cursor:pointer;">
  28.         <p style="    font-family: 'Hannari', serif;">{{ 'カテゴリ一覧 ▼'|trans }}</p>
  29.     </div>
  30.     <div class="ec-itemNav js-category-list slide-toggle">
  31.         <ul class="ec-itemNav__nav">
  32.             {% for Category in Categories %}
  33.                 <li>
  34.                     {{ tree(Category) }}
  35.                 </li>
  36.             {% endfor %}
  37.         </ul>
  38.     </div>
  39.     <div class="ec-itemNav">
  40.         <ul class="ec-itemNav__nav">
  41.             <li><a href="{{ url('user_data', {'route': 'about'}) }}" style="font-weight:bold;padding: 1em 10px; color:#654231; background: #ffffe8;">伊せ屋について</a></li>
  42.             <li><a href="{{ url('user_data', {'route': 'eat'}) }}" style="font-weight:bold;padding: 1em 10px;color:#654231; background: #ffffe8;">美味しい食べ方</a></li>
  43.             <li><a href="{{ url('user_data', {'route': 'faq'}) }}" style="font-weight:bold;padding: 1em 10px;color:#654231; background: #ffffe8;">Q&A</a></li>
  44.         </ul>
  45.     </div>
  46. </div>
  47. <style>
  48. /* 初期状態:閉じている */
  49. .slide-toggle {
  50.     max-height: 0;
  51.     overflow: hidden;
  52.     transition: max-height 0.4s ease;
  53. }
  54. /* 開いている状態 */
  55. .slide-toggle.open {
  56.     max-height: 1000px; /* 十分に大きければOK */
  57. }
  58. </style>
  59. <script>
  60. document.addEventListener('DOMContentLoaded', function () {
  61.     const toggleHeading = document.querySelector('.js-toggle-category');
  62.     const categoryList = document.querySelector('.js-category-list');
  63.     if (toggleHeading && categoryList) {
  64.         toggleHeading.addEventListener('click', function () {
  65.             categoryList.classList.toggle('open');
  66.         });
  67.     }
  68. });
  69. </script>