You are here

cheeseburger-menu.html.twig in Cheeseburger Menu 5.0.x

Same filename and directory in other branches
  1. 8.4 templates/cheeseburger-menu.html.twig
{% import _self as cheesebuger %}
{% if show_navigation %}
	<div{{side_navigation_menu_attribute}}>
		<div{{side_navigation_trigger_attribute}}>{{ close_icon|raw }}</div>

		{% for menu in tree %}
      {% if not menu.isNavigationTitleHidden %}
        <div {{ menu.getIdAsAttribute }} {{ menu.navigationItemAttribute }}>
          {% if menu.hasIcon %}
            {{ menu.icon|raw }}
          {% endif %}
          <span>{{ menu.title }}</span>
        </div>
      {% endif %}
			{% for menu_item in menu.getNavigationMenuItems() %}
				<div {{ menu.navigationItemAttribute }}>
					<a href="{{ menu_item.url }}">
						<span>{{ menu_item.title }}</span>
					</a>
				</div>
			{% endfor %}
		{% endfor %}
	</div>
{% endif %}

{# Each menu #}
<div{{main_navigation_attribute}}>
	{% if show_navigation == FALSE %}
		<div{{side_navigation_trigger_attribute}}>{{ close_icon|raw }}</div>
	{% endif %}
	{% for menu in tree %}
		<div {{ menu.getIdAsAttribute }} {{ menu.wrapperAttribute }}>
			{% if not menu.isTitleHidden %}
				<div {{ menu.titleAttribute }}>{{ menu.title }}</div>
			{% endif %}
			<ul
				class="cheeseburger-menu__mainmenu">
				{# Each menu item #}
				{% for menu_item in menu %}
					{{ cheesebuger.render_menu_item(menu_item, trigger_icon) }}
				{% endfor %}
			</ul>
		</div>
	{% endfor %}
</div>

{% macro render_menu_item(menu_item, trigger_icon) %}
	{% import _self as render_menu_item %}
	<li {{ menu_item.attribute }}>
		{% if menu_item.isLink() %}
			<a{{menu_item.labelAttribute}} href="{{ menu_item.url }}">
				<span>{{ menu_item.title }}</span>
			</a>
		{% else %}
			{% if menu_item.hasChild %}
				<span{{menu_item.labelAttribute}} data-cheeseburger-parent-trigger>
					<span>{{ menu_item.title }}</span>
				</span>
			{% else %}
				<span{{menu_item.labelAttribute}}>
					<span>{{ menu_item.title }}</span>
				</span>
			{% endif %}
		{% endif %}

		{% if menu_item.hasChild %}
			<span{{menu_item.triggerAttribute}} data-cheeseburger-parent-trigger>{{ trigger_icon|raw }}</span>
			<ul class="cheeseburger-menu__submenu">
				{% for child_menu_item in menu_item.children %}
					{{ render_menu_item.render_menu_item(child_menu_item, trigger_icon) }}
				{% endfor %}
			</ul>
		{% endif %}
	</li>
{% endmacro %}

File

templates/cheeseburger-menu.html.twig
View source
  1. {% import _self as cheesebuger %}
  2. {% if show_navigation %}
  3. <div{{side_navigation_menu_attribute}}>
  4. <div{{side_navigation_trigger_attribute}}>{{ close_icon|raw }}</div>
  5. {% for menu in tree %}
  6. {% if not menu.isNavigationTitleHidden %}
  7. <div {{ menu.getIdAsAttribute }} {{ menu.navigationItemAttribute }}>
  8. {% if menu.hasIcon %}
  9. {{ menu.icon|raw }}
  10. {% endif %}
  11. <span>{{ menu.title }}</span>
  12. </div>
  13. {% endif %}
  14. {% for menu_item in menu.getNavigationMenuItems() %}
  15. <div {{ menu.navigationItemAttribute }}>
  16. <a href="{{ menu_item.url }}">
  17. <span>{{ menu_item.title }}</span>
  18. </a>
  19. </div>
  20. {% endfor %}
  21. {% endfor %}
  22. </div>
  23. {% endif %}
  24. {# Each menu #}
  25. <div{{main_navigation_attribute}}>
  26. {% if show_navigation == FALSE %}
  27. <div{{side_navigation_trigger_attribute}}>{{ close_icon|raw }}</div>
  28. {% endif %}
  29. {% for menu in tree %}
  30. <div {{ menu.getIdAsAttribute }} {{ menu.wrapperAttribute }}>
  31. {% if not menu.isTitleHidden %}
  32. <div {{ menu.titleAttribute }}>{{ menu.title }}</div>
  33. {% endif %}
  34. <ul
  35. class="cheeseburger-menu__mainmenu">
  36. {# Each menu item #}
  37. {% for menu_item in menu %}
  38. {{ cheesebuger.render_menu_item(menu_item, trigger_icon) }}
  39. {% endfor %}
  40. </ul>
  41. </div>
  42. {% endfor %}
  43. </div>
  44. {% macro render_menu_item(menu_item, trigger_icon) %}
  45. {% import _self as render_menu_item %}
  46. <li {{ menu_item.attribute }}>
  47. {% if menu_item.isLink() %}
  48. <a{{menu_item.labelAttribute}} href="{{ menu_item.url }}">
  49. <span>{{ menu_item.title }}</span>
  50. </a>
  51. {% else %}
  52. {% if menu_item.hasChild %}
  53. <span{{menu_item.labelAttribute}} data-cheeseburger-parent-trigger>
  54. <span>{{ menu_item.title }}</span>
  55. </span>
  56. {% else %}
  57. <span{{menu_item.labelAttribute}}>
  58. <span>{{ menu_item.title }}</span>
  59. </span>
  60. {% endif %}
  61. {% endif %}
  62. {% if menu_item.hasChild %}
  63. <span{{menu_item.triggerAttribute}} data-cheeseburger-parent-trigger>{{ trigger_icon|raw }}</span>
  64. <ul class="cheeseburger-menu__submenu">
  65. {% for child_menu_item in menu_item.children %}
  66. {{ render_menu_item.render_menu_item(child_menu_item, trigger_icon) }}
  67. {% endfor %}
  68. </ul>
  69. {% endif %}
  70. </li>
  71. {% endmacro %}