Hi!
Is there a way to show the name i gave the page in the main-navigation on the page with a hubl-tag?
The text i want to show:
Thank you so much for your help
Pascal
Hey Kevin, thank you so much for your help.
When i use your code, i always get the first menu item, is this correct? I always need the navigation “label” of the active menu item. Is this even possible?
Thank you so much for your help and best regards.
Pascal
@hubspotWould be glad for some help ![]()
Hey @peesen
I see what you’re doing now.
Try something like this:
{% set node = menu(*menuId*) %}
{% for child in node.children %} {# loop through the menu #}
{% if child.activeNode == true %} {# test if the current menu child is active #}
{% set active_node = child.label %} {# declare a variable that we can use and test against later #}
{% endif %}{% endfor %}
{{ active_node }} {# display the label #}
Unfortunately I am unable to test this, so I hope its straight forward enough!
Hey @Kevin-C
I added the menu ID and tried to use your script the following:
{% set node = menu(32047489403) %}
{% for child in node.children %} {# loop through the menu #}
<span>Found nodes</span>
{% if child.activeNode == true %} {# test if the current menu child is active #}
<span>Found active node</span>
{% set active_node = child.label %} {# declare a variable that we can use and test against later #}
{% endif %}
{% endfor %}
{{ active_node }} {# display the label #}
The message “found nodes” i get on almost every page. Its strange that the number of nodes is not always the same. The message “found active node” i just get on some pages which looks randomy but i could never get the the output of the “active_node” label.
Thank you so much for your help so far. If you have any idea what could be wrong, i would be glad. Im maybe looking into another solution with a a text-field for every page where the name of the page has to be inserted manually again and i get the value from there.
Have a nice day and best regards
Pascal
This is not working in my case. I wrote an answer last week about it. Can maybe Hubspot get into this? I would love to get this done soon.
Thank you so much and best regards
Pascal
Hey Kevin, your solution did not work in my case. Did you check this in one of your projects?