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