modular.html.twig 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {% extends 'partials/base.html.twig' %}
  2. {% set show_onpage_menu = header.onpage_menu == true or header.onpage_menu is null %}
  3. {% macro pageLinkName(text) %}{{ text|lower|replace({' ':'_'}) }}{% endmacro %}
  4. {% block javascripts %}
  5. {% if show_onpage_menu %}
  6. {% do assets.add('theme://js/singlepagenav.min.js') %}
  7. {% endif %}
  8. {{ parent() }}
  9. {% endblock %}
  10. {% block bottom %}
  11. {{ parent() }}
  12. {% if show_onpage_menu %}
  13. <script>
  14. // singlePageNav initialization & configuration
  15. $('ul.navigation').singlePageNav({
  16. offset: $('#header').outerHeight(),
  17. filter: ':not(.external)',
  18. updateHash: true,
  19. currentClass: 'active'
  20. });
  21. </script>
  22. {% endif %}
  23. {% endblock %}
  24. {% block header_navigation %}
  25. {% if show_onpage_menu %}
  26. {% include 'partials/language-selector.html.twig' %}
  27. <ul class="navigation">
  28. {% for module in page.collection() %}
  29. {% set current_module = (module.active or module.activeChild) ? 'active' : '' %}
  30. <li><a class="{{ current_module }}" href="#{{ _self.pageLinkName(module.menu) }}">{{ module.menu }}</a></li>
  31. {% endfor %}
  32. {% for mitem in site.menu %}
  33. <li>
  34. <a {% if mitem.class %}class="{{ mitem.class }}"{% endif %} href="{{ mitem.url }}">
  35. {% if mitem.icon %}<i class="fa fa-{{ mitem.icon }}"></i>{% endif %}
  36. {{ mitem.text }}
  37. </a>
  38. </li>
  39. {% endfor %}
  40. </ul>
  41. {% else %}
  42. {{ parent() }}
  43. {% endif %}
  44. {% endblock %}
  45. {% block body %}
  46. <div id="{{ _self.pageLinkName(page.menu) }}">
  47. {{page.content}}
  48. </div>
  49. {% for module in page.collection() %}
  50. <div id="{{ _self.pageLinkName(module.menu) }}">
  51. {{ module.content }}
  52. </div>
  53. {% endfor %}
  54. {% endblock %}