custom/plugins/FourtwosixThemeExtension/src/Resources/views/storefront/layout/navigation/categories.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/layout/navigation/categories.html.twig' %}
  2. {% block layout_navigation_categories %}
  3.     {% set navigationMaxDepth = 3 %}
  4.     {% if not level %}
  5.         {% set level = 0 %}
  6.     {% endif %}
  7.     {% set activeId = page.header.navigation.active.id %}
  8.     {% set activePath = page.header.navigation.active.path %}
  9.     {% set allNavigationTree = [] %}
  10.     {% set ceiledNavigationCountDivision = (navigationTree|length / 4)|round(0, 'ceil') %}
  11.     {% set sortedNavigationTree = navigationTree|sort((a, b) => a.category.translated.name <=> b.category.translated.name) %}
  12.     {% for i in  0..3 %}
  13.         {% set indexOfSlice = i * ceiledNavigationCountDivision %}
  14.         {% set sliced = [sortedNavigationTree|slice(indexOfSlice, ceiledNavigationCountDivision)] %}
  15.         {% set  allNavigationTree = allNavigationTree|merge(sliced) %}
  16.     {% endfor %}
  17.     <div class="{% if level == 0 %}row {% endif %}navigation-flyout-categories is-level-{{ level }}">
  18.         {# @fourtwosix-edit: FV: Added the sorting here --------------------- #}
  19.         {% foreach allNavigationTree as  colNavigationTree  %}
  20.         <div class="{% if level == 0 %} col-3 {% endif %}navigation-flyout-col mb-0"> {# @fourtwosix-edit: add mb-0 #}
  21.             {% for treeItem in colNavigationTree %}
  22.                 {# @fourtwosix-edit: end -------------------------------------------- #}
  23.                 {% set id = treeItem.category.id %}
  24.                 {% set name = treeItem.category.translated.name %}
  25.                 {% set link = category_url(treeItem.category) %}
  26.                 {% block layout_navigation_categories_item %}
  27.                     {# @fourtwosix-edit: set always to col-3 before there was a check for categoryMedia #}
  28.                     {% block layout_navigation_categories_item_link %}
  29.                         {% if treeItem.category.type == 'folder' %}
  30.                             <div class="nav-item nav-link navigation-flyout-link is-level-{{ level }}"
  31.                                  title="{{ name }}">
  32.                                 <span itemprop="name">{{ name }}</span>
  33.                             </div>
  34.                         {% else %}
  35.                             <a class="nav-item nav-link navigation-flyout-link is-level-{{ level }}{% if id == activeId or id in activePath %} active{% endif %}"
  36.                                href="{{ link }}"
  37.                                itemprop="url"
  38.                                {% if category_linknewtab(treeItem.category) %}target="_blank"
  39.                                {% if treeItem.category.linkType == "external" %}rel="noopener noreferrer"{% endif %}
  40.                                     {% endif %}
  41.                                title="{{ name }}">
  42.                                 <span itemprop="name">{{ name }}</span>
  43.                             </a>
  44.                         {% endif %}
  45.                     {% endblock %}
  46.                     {% block layout_navigation_categories_recoursion %}
  47.                         {# @fourtwosix-edit: FV do not show subcategories here #}
  48.                     {% endblock %}
  49.                 {% endblock %}
  50.             {% endfor %}
  51.         </div>
  52.         {% endforeach %}
  53.     </div>
  54. {% endblock %}