templates/layout/nav/main-mobile-subnav.html.twig line 1

Open in your IDE?
  1. {% if not document is defined or not document %}
  2.     {% set document = pimcore_document(1) %}
  3. {% endif %}
  4. {% set navStartNode = document.getProperty('mainNavStartNode') %}
  5. {% if not 
  6.     (navStartNode is instanceof('\\Pimcore\\Model\\Document\\Page') 
  7.     or navStartNode is instanceof('\\Pimcore\\Model\\Document\\Folder')
  8.     or navStartNode is instanceof('\\Pimcore\\Model\\Document\\Link')
  9. ) %}
  10.     {% set navStartNode = pimcore_document(1) %}
  11. {% endif %}
  12. {% set mainNavigation = pimcore_build_nav({
  13.     active: document,
  14.     root: navStartNode
  15. }) %}
  16. {% set menuRenderer = pimcore_nav_renderer('menu') %}
  17. {% for page in mainNavigation %}
  18.     {% if page.isVisible() and menuRenderer.accept(page)  %}
  19.         {# has children #}
  20.         {% set hasChildren = false %}
  21.         {% for child in page.pages %}
  22.             {% if child._visible %}
  23.                 {% set hasChildren = true %}
  24.             {% endif %}
  25.         {% endfor %}
  26.         {# active #}
  27.         {% if page._active %}
  28.             {% set activeClass = 'active' %}
  29.         {% else %}
  30.             {% set activeClass = '' %}
  31.         {% endif %}
  32.         {# active child #}
  33.         {% set activeClass2 = '' %}
  34.         {% if page._active %}
  35.             {% for child in page.getPages() %}
  36.                 {% if child.isVisible() and menuRenderer.accept(child) %}
  37.                     {% if child._active %}
  38.                         {% set activeClass2 = 'open' %}
  39.                     {% endif %}
  40.                 {% endif %}
  41.             {% endfor %}
  42.         {% endif %}
  43.         {% if hasChildren %}
  44.             <div class="mobile-subnav {{ activeClass2 }}" id="subnav{{ page.id }}">
  45.                 <div class="subnav-container">
  46.                     <div class="scrollable">
  47.                         <div class="mobile-subnav-back" data-subnavback="subnav{{ page.id }}">
  48.                             {{ include('svg/header/mobile/accordion.html.twig') }}
  49.                             {# <span>{{ 'nav.mobile.back'|trans }}</span> #}
  50.                             <span>{{ page.getLabel() }}</span>
  51.                         </div>
  52.                         <ul class="{{ activeClass }}">
  53.                             {% for child in page.getPages() %}
  54.                                 {% if child.isVisible() and menuRenderer.accept(child) %}
  55.                                     
  56.                                     {# active #}
  57.                                     {% if child._active %}
  58.                                         {% set activeChildClass = 'active' %}
  59.                                     {% else %}
  60.                                         {% set activeChildClass = '' %}
  61.                                     {% endif %}
  62.                                     <li class="{{ activeChildClass }}">
  63.                                         <a href="{{ child.getHref() }}">{{ child.getLabel() }}</a>
  64.                                     </li>
  65.                                 {% endif %}
  66.                             {% endfor %}
  67.                         </ul>
  68.                     </div>
  69.                 </div>
  70.             </div>
  71.         {% endif %}
  72.     {% endif %}
  73. {% endfor %}