{% block megamenu_subcategories %}
{% set useCustomCategoryIcon = config('H1webMegaMenu.config.iconCustomField') %}
<div class="megamenu-sub-2{% if hideMenuSidebar %} megamenu-full{% endif %}"
{% if not hideMenuSidebar %}data-megamenu-sub-id="{{ categoryId }}"{% endif %}>
{% set activeId = page.header.navigation.active.id %}
{% set subcatAmount = config('H1webMegaMenu.config.amountSubcategories')|default(5) %}
{% set hideShowAll = config('H1webMegaMenu.config.hideShowAll') %}
{% set subcategoryColumns = config('H1webMegaMenu.config.selectSubcategoryColumns') %}
{% if hideMenuSidebar %}
{% set col = 'col-3' %}
{% else %}
{% if subcategoryColumns == 'col-4' %}
{% set col = 'col-3' %}
{% elseif subcategoryColumns == 'col-5' %}
{% set col = 'col-20-custom' %}
{% else %}
{% set col = 'col-4' %}
{% endif %}
{% endif %}
<div class="row">
{% for treeItem in navigationTree %}
{% if treeItem.category.childCount > 0 %}
{% set id = treeItem.category.id %}
{% set name = treeItem.category.translated.name %}
{% set link = category_url(treeItem.category) %}
{% if useCustomCategoryIcon %}
{% set icon = false %}
{% set categoryIconId = treeItem.category.translated.customFields.h1_mega_menu_category_icon %}
{% if categoryIconId %}
{% set mediaCollection = searchMedia([categoryIconId], context.context) %}
{% set categoryIcon = mediaCollection.get(categoryIconId) %}
{% set icon = categoryIcon %}
{% endif %}
{% else %}
{% set icon = treeItem.category.media %}
{% endif %}
{% block megamenu_subcategories_subs %}
<div class="{{ col }} mb-4">
{% block megamenu_subcategories_subs_link %}
<a class="megamenu-sub-2-link{% if id is same as(activeId) %} active{% endif %}"
href="{{ link }}"
itemprop="url"
{% if category_linknewtab(treeItem.category) %}target="_blank"{% endif %}
title="{{ name }}"
>
{% if icon %}
{% sw_thumbnails 'megamenu-icon' with {
media: icon,
sizes: {
'default': '20px'
},
attributes: {
'class': 'category-icon',
'alt': name,
'title': name,
'loading': 'lazy'
}
} %}
{% endif %}
<span itemprop="name">{{ name }}</span>
</a>
{% endblock %}
<ul{% if icon %} class="padding-left"{% endif %}>
{% for treeItem in treeItem.children|slice(0, subcatAmount) %}
<li>
{% sw_include '@Storefront/storefront/layout/navigation/megamenu/link.html.twig' with {
id: treeItem.category.id,
activeId: page.header.navigation.active.id,
name: treeItem.category.translated.name,
link: category_url(treeItem.category),
blank: category_linknewtab(treeItem.category)
} only %}
</li>
{% endfor %}
{% set countChildren = treeItem.children|length %}
{% if (hideShowAll == false) and (countChildren > subcatAmount) %}
<li class="showall">
<a href="{% if link %}{{ link }}{% else %}{{ seoUrl('frontend.navigation.page', { navigationId: id }) }}{% endif %}" title="{{ "h1.mega_menu.see_more_title_tag"|trans|sw_sanitize }} {{ name }}">
{{ "h1.mega_menu.see_more"|trans|sw_sanitize }}
</a>
</li>
{% endif %}
</ul>
</div>
{% endblock %}
{% endif %}
{% endfor %}
{% for treeItem in navigationTree|filter(treeItem => treeItem.category.childCount == 0)|batch(subcatAmount) %}
<div class="{{ col }} mb-4">
<ul class="mt-0 pl-0">
{% for item in treeItem %}
{% set id = item.category.id %}
{% set name = item.category.translated.name %}
{% set link = item.category.externalLink %}
{% if useCustomCategoryIcon %}
{% set icon = false %}
{% set categoryIconId = item.category.translated.customFields.h1_mega_menu_category_icon %}
{% if categoryIconId %}
{% set mediaCollection = searchMedia([categoryIconId], context.context) %}
{% set categoryIcon = mediaCollection.get(categoryIconId) %}
{% set icon = categoryIcon %}
{% endif %}
{% else %}
{% set icon = item.category.media %}
{% endif %}
<li>
<a class="megamenu-sub-2-link{% if id is same as(activeId) %} active{% endif %}"
href="{% if link %}{{ link }}{% else %}{{ seoUrl('frontend.navigation.page', { navigationId: id }) }}{% endif %}"
itemprop="url"
title="{{ name }}"
>
{% if icon %}
{% sw_thumbnails 'megamenu-icon' with {
media: icon,
sizes: {
'default': '20px'
},
attributes: {
'class': 'category-icon',
'alt': name,
'title': name,
'loading': 'lazy'
}
} %}
{% endif %}
<span itemprop="name">{{ name }}</span>
</a>
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
</div>
{% endblock %}