{% set navStartNode = document.getProperty("mainNavStartNode") %}
{% if document.getProperty('secondaryNavStartNode') %}
{% set navStartNode = document.getProperty("secondaryNavStartNode") %}
{% endif %}
{% set mainNavigation = pimcore_build_nav({active: document, root: navStartNode}) %}
{% set menuRenderer = pimcore_nav_renderer('menu') %}
<ul class="uk-navbar-nav apk-menu uk-width-1-1 uk-child-width-auto">
{# calcul du nombre maximum de pages visibles et valides #}
{% set totalPages = 0 %}
{% for page in mainNavigation %}
{% if page.isVisible() and menuRenderer.accept(page) %}
{% set totalPages = totalPages + 1 %}
{% endif %}
{% endfor %}
{% set p = 1 %}
{% for page in mainNavigation %}
{% if page.isVisible() and menuRenderer.accept(page) %}
{% set hasChildren = 0 %}
{% if page.hasPages() %}
{% for child in page.getPages() %}
{% if page.isVisible() and menuRenderer.accept(child) %}
{% set hasChildren = hasChildren + 1 %}
{% endif %}
{% endfor %}
{% endif %}
{# condition d'affichage du menu flex-right #}
{% if p - 0.5 == (totalPages / 2) %}
{% set isAlign = "apk-align-center" %}
{% elseif p <= (totalPages / 2)|round %}
{% set isAlign = "apk-align-left" %}
{% else %}
{% set isAlign = "apk-align-right" %}
{% endif %}
{% if hasChildren == 0 %}
{% if not page.getClass('apk-highlight-link') %}
<li class="{% if page.getActive(true) %}uk-active{% endif %} apk-highlight-link-container {{ isAlign }}">
<a href="{{ page.getHref() }}" class="{{ page.getClass() }}" {% if page.getTarget() != NULL %} target="{{ page.getTarget() }}" {% endif %}>
{{ page.getLabel()|trans }}
</a>
</li>
{% else %}
<li class="{% if page.getActive(true) %}uk-active{% endif %} {{ isAlign }}">
<a href="{{ page.getHref() }}" class="{{ page.getClass() }}" {% if page.getTarget() != NULL %} target="{{ page.getTarget() }}" {% endif %}>
{{ page.getLabel()|trans }}
</a>
</li>
{% endif %}
{% else %}
{% if not page.getClass('apk-highlight-link') %}
<li class="uk-parent apk-highlight-link-type {% if page.getActive(true) %}uk-active{% endif %} {{ isAlign }}">
{% else %}
<li class="uk-parent {% if page.getActive(true) %}uk-active{% endif %} {{ isAlign }}">
{% endif %}
{% if page.getClass('apk-highlight-link') %}
<a href="{{ page.getHref() }}" class="{{ page.getClass() }} apk-highlight-link-container" {% if page.getTarget() != NULL %} target="{{ page.getTarget() }}" {% endif %}>
{{ page.getLabel()|trans }}
<img class="uk-margin-small-left" uk-svg width="15" height="15" src="/static/img/pictos/chevron-down.svg" alt="">
</a>
{% else %}
<a href="{{ page.getHref() }}" class="{{ page.getClass() }}" {% if page.getTarget() != NULL %} target="{{ page.getTarget() }}" {% endif %}>
{{ page.getLabel()|trans }}
<i uk-icon="icon: chevron-down; ratio: 0.5"></i>
</a>
{% endif %}
{% set navBreakPoint = pimcore_website_config('main-nav-breakpoint') %}
{% if navBreakPoint is not empty %}
{% set countPage = page.getPages()|length %}
{% if countPage > breakpointChild %}
{% set countChild = (countPage / 2)|round %}
{% else %}
{% set countChild = null %}
{% endif %}
{% else %}
{% set countChild = null %}
{% endif %}
<div class="uk-navbar-dropdown {% if countChild == null %}uk-navbar-dropdown-width-2{% endif %} uk-border-rounded">
<div class="uk-navbar-dropdown-grid {% if countChild == null %}uk-child-width-1-1{% else %}uk-child-width-1-2{% endif %}" uk-grid>
<div>
<ul class="uk-nav uk-navbar-dropdown-nav uk-list-divider uk-text-uppercase">
{% set i = 1 %}
{% for child in page.getPages() %}
{% if child.isVisible() and menuRenderer.accept(child) %}
<li class="{% if child.getActive(true) %}uk-active{% endif %}">
<a href="{{ child.getHref() }}" class="{{ child.getClass() }}" {% if child.getTarget() != NULL %} target="{{ child.getTarget() }}" {% endif %}>
{{ child.getLabel()|trans }}
</a>
</li>
{% endif %}
{% if (countChild != null) and (p == countChild) %}
</ul>
</div>
<div>
<ul class="uk-nav uk-navbar-dropdown-nav uk-list-divider uk-text-uppercase">
{% endif %}
{% set i = i + 1 %}
{% endfor %}
</ul>
</div>
</div>
</div>
</li>
{% endif %}
{% set p = p + 1 %}
{% endif %}
{% endfor %}
</ul>