modular.html.twig 2.1 KB

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