{% 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!
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?
{% 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!
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.