{% extends 'partials/base.html.twig' %}

{% set show_onpage_menu = header.onpage_menu == true or header.onpage_menu is null %}
{% set cc = taxonomy.findTaxonomy({'category':'sous-menu'}) %}

{% macro pageLinkName(text) %}{{ text|lower|replace({'01._':'','02._':'','03._':'','04._':'','05._':'','06._':'','07._':'','08._':'','09._':''}) }}{% endmacro %}

{% block javascripts %}
    {% if show_onpage_menu %}
    {% endif %}
    {{ parent() }}
{% endblock %}

{% block header_navigation %}
    {% if show_onpage_menu %}
        <ul class="navigation">
        {% for module in page.collection() %}
            <li class="{{module.header.body_classes}}">
              <a href="#{{ _self.pageLinkName(module.folder) }}">{{ module.menu }}</a>
                {% for child in module.collection %}
                  {% if child in cc %}
                  <ol>
                    <a href="#{{ _self.pageLinkName(child.folder) }}">{{ child.menu }}</a>
                </ol>
                  {% endif %}
                {% endfor %}
            </li>
        {% endfor %}

        </ul>
    {% else %}
        {{  parent() }}
    {% endif %}
{% endblock %}

{% block content %}
    {{ page.content }}
    {% for module in page.collection() %}
        <div id="{{ _self.pageLinkName(module.folder) }}" class="column ">
        {{ module.content }}
        </div>
    {% endfor %}
{% endblock %}
