templates/includes/main-nav.html.twig line 1

Open in your IDE?
  1. {% set navStartNode = document.getProperty("mainNavStartNode") %}
  2. {% if document.getProperty('secondaryNavStartNode') %}
  3.     {% set navStartNode = document.getProperty("secondaryNavStartNode") %}
  4. {% endif %}
  5. {% set mainNavigation = pimcore_build_nav({active: document, root: navStartNode}) %}
  6. {% set menuRenderer = pimcore_nav_renderer('menu') %}
  7. <ul class="uk-navbar-nav apk-menu uk-width-1-1 uk-child-width-auto">
  8.     {# calcul du nombre maximum de pages visibles et valides #}
  9.     {% set totalPages = 0 %}
  10.     {% for page in mainNavigation %}
  11.         {% if page.isVisible() and menuRenderer.accept(page) %}
  12.             {% set totalPages = totalPages + 1 %}
  13.         {% endif %}
  14.     {% endfor %}
  15.     {% set p = 1 %}
  16.     {% for page in mainNavigation %}
  17.         {% if page.isVisible() and menuRenderer.accept(page) %}
  18.                 
  19.             {% set hasChildren = 0 %}
  20.             
  21.             {% if page.hasPages() %}
  22.                 {% for child in page.getPages() %}
  23.                     {% if page.isVisible() and menuRenderer.accept(child) %}
  24.                         {% set hasChildren = hasChildren + 1 %}
  25.                     {% endif %}
  26.                 {% endfor %}
  27.             {% endif %}
  28.             {# condition d'affichage du menu flex-right #}
  29.             {% if p - 0.5 == (totalPages / 2) %}
  30.                 {% set isAlign = "apk-align-center" %}
  31.             {% elseif  p <= (totalPages / 2)|round %}
  32.                 {% set isAlign = "apk-align-left" %}
  33.             {% else %}
  34.                 {% set isAlign = "apk-align-right" %}
  35.             {% endif %}
  36.             {% if hasChildren == 0 %}
  37.                 {% if not page.getClass('apk-highlight-link') %}
  38.                 
  39.                     <li class="{% if page.getActive(true) %}uk-active{% endif %} apk-highlight-link-container {{ isAlign }}">
  40.                         <a href="{{ page.getHref() }}" class="{{ page.getClass() }}" {% if page.getTarget() != NULL %} target="{{ page.getTarget() }}" {% endif %}>
  41.                             {{ page.getLabel()|trans }}
  42.                         </a>
  43.                     </li>
  44.                 {% else %}
  45.                     <li class="{% if page.getActive(true) %}uk-active{% endif %} {{ isAlign }}">
  46.                         <a href="{{ page.getHref() }}" class="{{ page.getClass() }}" {% if page.getTarget() != NULL %} target="{{ page.getTarget() }}" {% endif %}>
  47.                             {{ page.getLabel()|trans }}
  48.                         </a>
  49.                     </li>
  50.                 {% endif %}
  51.             {% else %}
  52.                 {% if not page.getClass('apk-highlight-link') %}
  53.                     <li class="uk-parent apk-highlight-link-type {% if page.getActive(true) %}uk-active{% endif %} {{ isAlign }}">
  54.                 {% else %}
  55.                     <li class="uk-parent {% if page.getActive(true) %}uk-active{% endif %} {{ isAlign }}">
  56.                 {% endif %}
  57.                     {% if page.getClass('apk-highlight-link') %}
  58.                         <a href="{{ page.getHref() }}" class="{{ page.getClass() }} apk-highlight-link-container" {% if page.getTarget() != NULL %} target="{{ page.getTarget() }}" {% endif %}>
  59.                             {{ page.getLabel()|trans }}
  60.                             <img class="uk-margin-small-left" uk-svg width="15" height="15" src="/static/img/pictos/chevron-down.svg" alt="">
  61.                         </a>
  62.                     {% else %}
  63.                         <a href="{{ page.getHref() }}" class="{{ page.getClass() }}" {% if page.getTarget() != NULL %} target="{{ page.getTarget() }}" {% endif %}>
  64.                             {{ page.getLabel()|trans }}
  65.                             <i uk-icon="icon: chevron-down; ratio: 0.5"></i>
  66.                         </a>
  67.                     {% endif %}
  68.                         {% set navBreakPoint = pimcore_website_config('main-nav-breakpoint') %}
  69.                         {% if navBreakPoint is not empty  %}
  70.                             {% set countPage = page.getPages()|length %}
  71.                             {% if countPage > breakpointChild %}
  72.                                 {% set countChild = (countPage / 2)|round %}
  73.                             {% else %}
  74.                                 {% set countChild = null %}
  75.                             {% endif %}
  76.                         {% else %}
  77.                             {% set countChild = null %}
  78.                         {% endif %}
  79.                         <div class="uk-navbar-dropdown {% if countChild == null %}uk-navbar-dropdown-width-2{% endif %} uk-border-rounded">
  80.                             <div class="uk-navbar-dropdown-grid {% if countChild == null %}uk-child-width-1-1{% else %}uk-child-width-1-2{% endif %}" uk-grid>
  81.                                 <div>
  82.                                     <ul class="uk-nav uk-navbar-dropdown-nav uk-list-divider uk-text-uppercase">
  83.                                         {% set i = 1 %}
  84.                                         {% for child in page.getPages() %}
  85.                                             {% if child.isVisible() and menuRenderer.accept(child) %}
  86.                                                 <li class="{% if child.getActive(true) %}uk-active{% endif %}">
  87.                                                     <a href="{{ child.getHref() }}" class="{{ child.getClass() }}" {% if child.getTarget() != NULL %} target="{{ child.getTarget() }}" {% endif %}>
  88.                                                         {{ child.getLabel()|trans }}
  89.                                                     </a>
  90.                                                 </li>
  91.                                             {% endif %}
  92.                                             {% if (countChild != null) and (p == countChild) %}
  93.                                                 </ul>
  94.                                             </div>
  95.                                             <div>
  96.                                                 <ul class="uk-nav uk-navbar-dropdown-nav uk-list-divider uk-text-uppercase">
  97.                                             {% endif %}
  98.                                             {% set i = i + 1 %}
  99.                                         {% endfor %}
  100.                                     </ul>
  101.                                 </div>
  102.                             </div>
  103.                         </div>
  104.                     </li>
  105.             {% endif %}
  106.             {% set p = p + 1 %}
  107.         {% endif %}
  108.     {% endfor %}
  109. </ul>