Files
wc-bootstrap/templates/global/category-tree.html.twig

35 lines
1.2 KiB
Twig
Raw Normal View History

{#
# Product Category Tree (Bootstrap 5)
#
# Renders a hierarchical product category navigation with collapsible
# sub-levels, up to 3 levels deep. Uses Bootstrap 5 list-group and
# collapse components for responsive tree navigation.
#
# Expected context:
# categories - Hierarchical array from wc_bootstrap_get_category_tree()
# shop_url - URL to the main shop page
#
# @package WcBootstrap
# @since 0.1.7
#}
{% if categories is not empty %}
<nav aria-label="{{ __('Product categories', 'wc-bootstrap') }}">
<h3 class="sidebar-heading h6 text-uppercase fw-semibold">
{{ __('Categories', 'wc-bootstrap') }}
</h3>
<ul class="list-group list-group-flush category-tree">
<li class="list-group-item px-0 py-1">
<a href="{{ shop_url }}"
class="category-tree-link d-block text-decoration-none py-1 px-2 rounded{% if current_cat == 0 %} active fw-semibold{% endif %}">
{{ __('All products', 'wc-bootstrap') }}
</a>
</li>
{% for cat in categories %}
{% include 'global/category-tree-node.html.twig' with { node: cat, level: 1 } only %}
{% endfor %}
</ul>
</nav>
{% endif %}