{#
This file is part of EC-CUBE
Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
http://www.ec-cube.co.jp/
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% set Categories = repository('Eccube\\Entity\\Category').getList() %}
{% macro tree(Category) %}
{% from _self import tree %}
<a href="{{ url('product_list') }}?category_id={{ Category.id }}">
{{ Category.name }}
</a>
{% if Category.children|length > 0 %}
<ul>
{% for ChildCategory in Category.children %}
<li>
{{ tree(ChildCategory) }}
</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
{# @see https://github.com/bolt/bolt/pull/2388 #}
{% from _self import tree %}
<div class="ec-headerCategoryArea">
<div class="ec-headerCategoryArea__heading js-toggle-category" style="cursor:pointer;">
<p style=" font-family: 'Hannari', serif;">{{ 'カテゴリ一覧 ▼'|trans }}</p>
</div>
<div class="ec-itemNav js-category-list slide-toggle">
<ul class="ec-itemNav__nav">
{% for Category in Categories %}
<li>
{{ tree(Category) }}
</li>
{% endfor %}
</ul>
</div>
<div class="ec-itemNav">
<ul class="ec-itemNav__nav">
<li><a href="{{ url('user_data', {'route': 'about'}) }}" style="font-weight:bold;padding: 1em 10px; color:#654231; background: #ffffe8;">伊せ屋について</a></li>
<li><a href="{{ url('user_data', {'route': 'eat'}) }}" style="font-weight:bold;padding: 1em 10px;color:#654231; background: #ffffe8;">美味しい食べ方</a></li>
<li><a href="{{ url('user_data', {'route': 'faq'}) }}" style="font-weight:bold;padding: 1em 10px;color:#654231; background: #ffffe8;">Q&A</a></li>
</ul>
</div>
</div>
<style>
/* 初期状態:閉じている */
.slide-toggle {
max-height: 0;
overflow: hidden;
transition: max-height 0.4s ease;
}
/* 開いている状態 */
.slide-toggle.open {
max-height: 1000px; /* 十分に大きければOK */
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function () {
const toggleHeading = document.querySelector('.js-toggle-category');
const categoryList = document.querySelector('.js-category-list');
if (toggleHeading && categoryList) {
toggleHeading.addEventListener('click', function () {
categoryList.classList.toggle('open');
});
}
});
</script>