2026-03-29 15:19:53 +02:00
|
|
|
{#
|
|
|
|
|
# Single Category Tree Node (recursive)
|
|
|
|
|
#
|
2026-03-29 15:42:35 +02:00
|
|
|
# Renders one category as a list-group-item-action link with optional
|
2026-03-29 16:02:13 +02:00
|
|
|
# collapsible nested children. Included recursively.
|
2026-03-29 15:19:53 +02:00
|
|
|
#
|
|
|
|
|
# Expected context:
|
|
|
|
|
# node - Category node from wc_bootstrap_get_category_tree()
|
|
|
|
|
# level - Current nesting depth (1-3)
|
|
|
|
|
#
|
|
|
|
|
# @package WcBootstrap
|
|
|
|
|
# @since 0.1.7
|
|
|
|
|
#}
|
|
|
|
|
|
2026-03-29 15:42:35 +02:00
|
|
|
{% set has_children = node.children is not empty %}
|
|
|
|
|
{% set is_open = node.is_active or node.is_ancestor %}
|
|
|
|
|
|
2026-03-29 16:02:13 +02:00
|
|
|
<a href="{{ node.url }}"
|
|
|
|
|
class="list-group-item list-group-item-action border-0 py-1 d-flex align-items-center{% if node.is_active %} active{% endif %}"
|
|
|
|
|
style="padding-left: {{ 0.75 + (level - 1) * 1 }}rem;"
|
|
|
|
|
{% if node.is_active %}aria-current="page"{% endif %}>
|
|
|
|
|
<span class="flex-grow-1">{{ node.name }}</span>
|
|
|
|
|
<small class="text-body-secondary ms-1">({{ node.count }})</small>
|
2026-03-29 15:42:35 +02:00
|
|
|
{% if has_children %}
|
2026-03-29 16:02:13 +02:00
|
|
|
<span class="category-tree-toggle ms-1"
|
|
|
|
|
role="button"
|
|
|
|
|
data-bs-toggle="collapse"
|
|
|
|
|
data-bs-target="#cat-{{ node.term_id }}"
|
|
|
|
|
aria-expanded="{{ is_open ? 'true' : 'false' }}"
|
|
|
|
|
aria-controls="cat-{{ node.term_id }}"
|
|
|
|
|
aria-label="{{ __('Toggle subcategories', 'wc-bootstrap') }}"
|
|
|
|
|
onclick="event.preventDefault(); event.stopPropagation();">
|
|
|
|
|
<i class="bi bi-chevron-down small" aria-hidden="true"></i>
|
|
|
|
|
</span>
|
2026-03-29 15:19:53 +02:00
|
|
|
{% endif %}
|
2026-03-29 16:02:13 +02:00
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
{% if has_children %}
|
|
|
|
|
<div class="collapse{{ is_open ? ' show' : '' }}" id="cat-{{ node.term_id }}">
|
|
|
|
|
{% for child in node.children %}
|
|
|
|
|
{% include 'global/category-tree-node.html.twig' with { node: child, level: level + 1 } only %}
|
|
|
|
|
{% endfor %}
|
|
|
|
|
</div>
|
|
|
|
|
{% endif %}
|