modular.html.twig 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 hero %}
  45. {% for module in page.collection() if module.template == 'modular/hero' %}
  46. <div id="{{ _self.pageLinkName(module.menu) }}"></div>
  47. {{ module.content }}
  48. {% endfor %}
  49. {% endblock %}
  50. {% block body %}
  51. {% for module in page.collection() if module.template != 'modular/hero' %}
  52. <div id="{{ _self.pageLinkName(module.menu) }}"></div>
  53. {{ module.content }}
  54. {% endfor %}
  55. {% endblock %}