Files
wc-bootstrap/templates/global/category-tree.html.twig
magdev 9860a184cd
All checks were successful
Create Release Package / PHP Lint (push) Successful in 1m4s
Create Release Package / PHPUnit Tests (push) Successful in 50s
Create Release Package / Build Release (push) Successful in 58s
Add product category tree sidebar to archive and single product pages (v0.1.7)
Hierarchical category navigation with collapsible sub-levels up to 3 levels
deep, using Bootstrap 5 list-group and collapse components. Sidebar renders
on both archive/shop and single product pages with responsive offcanvas on
mobile. Active category highlighting and ancestor auto-expand for intuitive
navigation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 15:19:53 +02:00

35 lines
1.2 KiB
Twig

{#
# 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 %}