custom/static-plugins/NdVoorwindenTheme/src/Resources/views/storefront/layout/navigation/offcanvas/categories.html.twig line 1

Open in your IDE?
  1. {# @var navigation \Shopware\Core\Content\Category\Tree\Tree #}
  2. {% set activeId = navigation.active.id ?? context.salesChannel.navigationCategoryId %}
  3. {% set isRoot = activeId == context.salesChannel.navigationCategoryId %}
  4. {% set hasNoChildren = navigation.active.childCount == 0 and navigation.active.level == 2 %}
  5. {# Make sure the navigation does not go deeper than 3 levels, if so, reach back to the parent #}
  6. {% if navigation.active.level == 3 %}
  7.     {# Custom work to select the parent of the current child #}
  8.     {% set children = navigation.children(navigation.active.parentId) %}
  9.     {% set active = navigation.children(navigation.active.parentId).active %}
  10. {% elseif hasNoChildren %}
  11.     {# Custom work to check if a second level item has no children (and thus is a page without sub-categories) #}
  12.     {% set children = navigation %}
  13.     {% set active = navigation.active %}
  14. {% else %}
  15.     {# Default shopware settings #}
  16.     {% set children = navigation.children(activeId) %}
  17.     {% set active = navigation.active %}
  18. {% endif %}
  19. {% set headerNavigation = 'Home' in active.breadcrumb %}
  20. {% if headerNavigation == false %}
  21.     {# Check if the navigation is from the Header menu, of else (footer). #}
  22.     {# TODO make foolproof. Not fully tested. #}
  23.     {% set children = navigation %}
  24.     {% set active = false %}
  25. {% endif %}
  26. {% block layout_navigation_offcanvas_navigation_categories %}
  27.     <div class="navigation-offcanvas-container js-navigation-offcanvas mb-6">
  28.         <div class="navigation-offcanvas-overlay-content js-navigation-offcanvas-overlay-content">
  29.             {% if (not isRoot) and (hasNoChildren != true) and (headerNavigation) %}
  30.                 {% sw_include '@Storefront/storefront/layout/navigation/offcanvas/back-link.html.twig' with { item: active } %}
  31.             {% endif %}
  32.             <ul class="navigation-offcanvas-list">
  33.                 {% if (not isRoot) and (page.navigation.active.type != "folder") and (hasNoChildren != true) and (headerNavigation) %}
  34.                     {% sw_include '@Storefront/storefront/layout/navigation/offcanvas/show-active-link.html.twig' with { item: active } %}
  35.                 {% endif %}
  36.                 {% set allowListAddition = ['inspiration', 'department', 'brands'] %}
  37.                 {% set hasListAddition = false %}
  38.                 {% for allowAddition in allowListAddition %}
  39.                     {% set categoryName = active.name ?? active.translated.name %}
  40.                     {% set additionalMenuId = categoryName|lower %}
  41.                     {% set additionMenus = page.extensions.additional_menus.get(allowAddition ~ '-' ~ additionalMenuId) %}
  42.                     {% if additionMenus %}
  43.                         {% set hasListAddition = true %}
  44.                         {% break %}
  45.                     {% endif %}
  46.                 {% endfor %}
  47.                 {% if hasListAddition %}
  48.                     <li class="navigation-offcanvas-list-item">
  49.                         <div class="navigation-offcanvas-link uppercase nav-item nav-link flex justify-between items-center p-4 pb-1 text-base font-bold transition hover:text-grey-600">
  50.                             <span itemprop="name">{{ 'themeGlobal.navigationCategories'|trans|sw_sanitize }}</span>
  51.                         </div>
  52.                         <ul>
  53.                             {# @var item \Shopware\Core\Content\Category\Tree\TreeItem #}
  54.                             {% for item in children.tree %}
  55.                                 {% if not bottomMenu %}
  56.                                     {% set item = item.category %}
  57.                                 {% endif %}
  58.                                 {% sw_include '@Storefront/storefront/layout/navigation/offcanvas/addition-item-link.html.twig' with { item: item, activeId: activeId } %}
  59.                             {% endfor %}
  60.                         </ul>
  61.                     </li>
  62.                     {% for allowAddition in allowListAddition %}
  63.                         {% set categoryName = active.name ?? active.translated.name %}
  64.                         {% set additionalMenuId = categoryName|lower %}
  65.                         {% set additionMenus = page.extensions.additional_menus.get(allowAddition ~ '-' ~ additionalMenuId) %}
  66.                         {% if additionMenus %}
  67.                             <li class="navigation-offcanvas-list-item">
  68.                                 <div class="navigation-offcanvas-link uppercase nav-item nav-link flex justify-between items-center p-4 pb-1 text-base font-bold transition hover:text-grey-600">
  69.                                     {% set additionMenuSnippetKey = 'themeGlobal.navigation' ~ allowAddition|capitalize %}
  70.                                     <span itemprop="name">{{ additionMenuSnippetKey|trans|sw_sanitize }}</span>
  71.                                 </div>
  72.                                 <ul>
  73.                                     {% for additionMenu in additionMenus.elements %}
  74.                                         {% sw_include '@Storefront/storefront/layout/navigation/offcanvas/addition-item-link.html.twig' with { item: additionMenu, activeId: activeId } %}
  75.                                     {% endfor %}
  76.                                 </ul>
  77.                             </li>
  78.                         {% endif %}
  79.                     {% endfor %}
  80.                 {% else %}
  81.                     {# @var item \Shopware\Core\Content\Category\Tree\TreeItem #}
  82.                     {% for item in children.tree %}
  83.                         {% sw_include '@Storefront/storefront/layout/navigation/offcanvas/item-link.html.twig' with { item: item, activeId: activeId } %}
  84.                     {% endfor %}
  85.                 {% endif %}
  86.             </ul>
  87.             {% set bottomMenu = page.header.extensions.additional_menus.get('bottom-menu') %}
  88.             {% if bottomMenu and isRoot %}
  89.                 <ul class="bottom-menu">
  90.                     {% for item in bottomMenu %}
  91.                         {% sw_include '@Storefront/storefront/layout/navigation/offcanvas/item-link.html.twig' with {
  92.                             bottomMenu: true,
  93.                             item: item,
  94.                             activeId: activeId
  95.                         } %}
  96.                     {% endfor %}
  97.                 </ul>
  98.             {% endif %}
  99.         </div>
  100.     </div>
  101. {% endblock %}