modular.html.twig 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. $('#navbar').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 class="{{ current_module }}"><a href="#{{ _self.pageLinkName(module.menu) }}">{{ module.menu }}</a></li>
  30. {% endfor %}
  31. {% for mitem in site.menu %}
  32. <li>
  33. <a 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 content %}
  45. {{ page.content }}
  46. {% for module in page.collection() %}
  47. <div id="{{ _self.pageLinkName(module.menu) }}"></div>
  48. {{ module.content }}
  49. {% endfor %}
  50. {% endblock %}