custom/plugins/H1webMegaMenu/src/Resources/views/storefront/layout/navigation/megamenu/subcategories.html.twig line 1

Open in your IDE?
  1. {% block megamenu_subcategories %}
  2.     {% set useCustomCategoryIcon = config('H1webMegaMenu.config.iconCustomField') %}
  3.     <div class="megamenu-sub-2{% if hideMenuSidebar %} megamenu-full{% endif %}"
  4.          {% if not hideMenuSidebar %}data-megamenu-sub-id="{{ categoryId }}"{% endif %}>
  5.         {% set activeId = page.header.navigation.active.id %}
  6.         {% set subcatAmount = config('H1webMegaMenu.config.amountSubcategories')|default(5) %}
  7.         {% set hideShowAll = config('H1webMegaMenu.config.hideShowAll') %}
  8.         {% set subcategoryColumns = config('H1webMegaMenu.config.selectSubcategoryColumns') %}
  9.         {% if hideMenuSidebar %}
  10.             {% set col = 'col-3' %}
  11.         {% else %}
  12.             {% if subcategoryColumns == 'col-4' %}
  13.                 {% set col = 'col-3' %}
  14.             {% elseif subcategoryColumns == 'col-5' %}
  15.                 {% set col = 'col-20-custom' %}
  16.             {% else %}
  17.                 {% set col = 'col-4' %}
  18.             {% endif %}
  19.         {% endif %}
  20.         <div class="row">
  21.             {% for treeItem in navigationTree %}
  22.                 {% if treeItem.category.childCount > 0 %}
  23.                     {% set id = treeItem.category.id %}
  24.                     {% set name = treeItem.category.translated.name %}
  25.                     {% set link = category_url(treeItem.category) %}
  26.                     {% if useCustomCategoryIcon %}
  27.                         {% set icon = false %}
  28.                         {% set categoryIconId = treeItem.category.translated.customFields.h1_mega_menu_category_icon %}
  29.                         {% if categoryIconId %}
  30.                             {% set mediaCollection = searchMedia([categoryIconId], context.context) %}
  31.                             {% set categoryIcon = mediaCollection.get(categoryIconId) %}
  32.                             {% set icon = categoryIcon %}
  33.                         {% endif %}
  34.                     {% else %}
  35.                         {% set icon = treeItem.category.media %}
  36.                     {% endif %}
  37.                     {% block megamenu_subcategories_subs %}
  38.                         <div class="{{ col }} mb-4">
  39.                             {% block megamenu_subcategories_subs_link %}
  40.                                 <a class="megamenu-sub-2-link{% if id is same as(activeId) %} active{% endif %}"
  41.                                    href="{{ link }}"
  42.                                    itemprop="url"
  43.                                    {% if category_linknewtab(treeItem.category) %}target="_blank"{% endif %}
  44.                                    title="{{ name }}"
  45.                                 >
  46.                                     {% if icon %}
  47.                                         {% sw_thumbnails 'megamenu-icon' with {
  48.                                             media: icon,
  49.                                             sizes: {
  50.                                                 'default': '20px'
  51.                                             },
  52.                                             attributes: {
  53.                                                 'class': 'category-icon',
  54.                                                 'alt': name,
  55.                                                 'title': name,
  56.                                                 'loading': 'lazy'
  57.                                             }
  58.                                         } %}
  59.                                     {% endif %}
  60.                                     <span itemprop="name">{{ name }}</span>
  61.                                 </a>
  62.                             {% endblock %}
  63.                             <ul{% if icon %} class="padding-left"{% endif %}>
  64.                                 {% for treeItem in treeItem.children|slice(0, subcatAmount) %}
  65.                                     <li>
  66.                                         {% sw_include '@Storefront/storefront/layout/navigation/megamenu/link.html.twig' with {
  67.                                             id: treeItem.category.id,
  68.                                             activeId: page.header.navigation.active.id,
  69.                                             name: treeItem.category.translated.name,
  70.                                             link: category_url(treeItem.category),
  71.                                             blank: category_linknewtab(treeItem.category)
  72.                                         } only %}
  73.                                     </li>
  74.                                 {% endfor %}
  75.                                 {% set countChildren = treeItem.children|length %}
  76.                                 {% if (hideShowAll == false) and (countChildren > subcatAmount) %}
  77.                                 <li class="showall">
  78.                                     <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 }}">
  79.                                         {{ "h1.mega_menu.see_more"|trans|sw_sanitize }}
  80.                                     </a>
  81.                                 </li>
  82.                                 {% endif %}
  83.                             </ul>
  84.                         </div>
  85.                     {% endblock %}
  86.                 {% endif %}
  87.             {% endfor %}
  88.             {% for treeItem in navigationTree|filter(treeItem => treeItem.category.childCount == 0)|batch(subcatAmount) %}
  89.                 <div class="{{ col }} mb-4">
  90.                     <ul class="mt-0 pl-0">
  91.                         {% for item in treeItem %}
  92.                             {% set id = item.category.id %}
  93.                             {% set name = item.category.translated.name %}
  94.                             {% set link = item.category.externalLink %}
  95.                             {% if useCustomCategoryIcon %}
  96.                                 {% set icon = false %}
  97.                                 {% set categoryIconId = item.category.translated.customFields.h1_mega_menu_category_icon %}
  98.                                 {% if categoryIconId %}
  99.                                     {% set mediaCollection = searchMedia([categoryIconId], context.context) %}
  100.                                     {% set categoryIcon = mediaCollection.get(categoryIconId) %}
  101.                                     {% set icon = categoryIcon %}
  102.                                 {% endif %}
  103.                             {% else %}
  104.                                 {% set icon = item.category.media %}
  105.                             {% endif %}
  106.                             <li>
  107.                                 <a class="megamenu-sub-2-link{% if id is same as(activeId) %} active{% endif %}"
  108.                                    href="{% if link %}{{ link }}{% else %}{{ seoUrl('frontend.navigation.page', { navigationId: id }) }}{% endif %}"
  109.                                    itemprop="url"
  110.                                    title="{{ name }}"
  111.                                 >
  112.                                     {% if icon %}
  113.                                         {% sw_thumbnails 'megamenu-icon' with {
  114.                                             media: icon,
  115.                                             sizes: {
  116.                                                 'default': '20px'
  117.                                             },
  118.                                             attributes: {
  119.                                                 'class': 'category-icon',
  120.                                                 'alt': name,
  121.                                                 'title': name,
  122.                                                 'loading': 'lazy'
  123.                                             }
  124.                                         } %}
  125.                                     {% endif %}
  126.                                     <span itemprop="name">{{ name }}</span>
  127.                                 </a>
  128.                             </li>
  129.                         {% endfor %}
  130.                     </ul>
  131.                 </div>
  132.             {% endfor %}
  133.         </div>
  134.     </div>
  135. {% endblock %}