Hello,
I am trying to implement own (very simplified, semantic and minimum wrappers) html markup for menus in HubL. Default markup from menu module has several problems (including absence of nav tag and crazy amount of useless attributes and classes).
Attempt #1: Get menu data from menu module with export_to_template_context
Putting a classic Advanced Menu module and exporting it to template context makes like this:
{% menu "menu_tag" site_map_name="Menu name in settings", overrideable=True, root_type="site_root", flyouts="true", max_levels="2", flow="horizontal", label="Menu name in editor", export_to_template_context=True %}
does make the page being able to choose the menu for the page and givew me some of the information about the menu in widget_data.menu_tag, but I cannot see the menu items themselves. The widget_data.menu_tag object only extracts: site_map_name, root_type, max_levels, parent_widget_container, label, flyouts, export_to_template_context, flow and overrideable.
Q: Is there any data structure there that I am missing? Is there any way to access Advance Menu items from widget_data?
Attempt #2: Use HubL menu function (HubL functions - HubSpot docs)
With this
{% set node = menu(987) %}
{% for child in node.children %}
{{ child.label }}
{% endfor %}
I am able to generate a fully custom markup, but I need a menu_id parameter as an integer, so I have to set the menu id in the template code so it’s not possible to change that per page. I tried using widget_data.menu_tag.site_map_name as a parameter after using Attempt 1 code, but it’s not integer.
Q: Any idea on how to get integer menu_id from Advanced Menu widget_data?
