modular.html.twig 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. <ul class="navigation">
  27. {% for module in page.collection() %}
  28. {% set current_module = (module.active or module.activeChild) ? 'active' : '' %}
  29. <li><a class="{{ current_module }}" href="#{{ _self.pageLinkName(module.menu) }}">{{ module.menu }}</a></li>
  30. {% endfor %}
  31. {% for mitem in site.menu %}
  32. <li>
  33. <a {% if mitem.class %}class="{{ mitem.class }}"{% endif %} href="{{ mitem.url }}">
  34. {% if mitem.icon %}<i class="fa fa-{{ mitem.icon }}"></i>{% endif %}
  35. {{ mitem.text }}
  36. </a>
  37. </li>
  38. {% endfor %}
  39. </ul>
  40. {% else %}
  41. {{ parent() }}
  42. {% endif %}
  43. {% endblock %}
  44. {% block body %}
  45. {% for module in page.collection %}
  46. <div id="{{ _self.pageLinkName(module.folder)|replace({"0":"", "1":"", "2":"", "3":"", "4":"", "5":"", "6":"", "7":"", "8":"", "9":"", ".":"","_":"" }) }}">
  47. {{ module.content }}
  48. </div>
  49. {% endfor %}
  50. {% endblock %}