I have a controller which returns all menus. From twig file, i use to access controller to get all menus.
I could just see all my menus in my twig file.
Code:
Twig File :
{% set menulist%}{%render url('get_all_menus')%}{% endset %}
I use for loop to print my menu name. Like
{% for menu in menulist %}
{{menu.MenuName}}
{%endfor%}
But I don't get any values from the above for loop. When I use dump(menu-list) I get result as
[{"FunctionName":"Home","ModuleName":null,"SubModuleName":null,"PageURL":"home_page","AccessLevel":"2"}]
Which is a JSON data that I return from my controller. How can i get the values from my for loop? Am i making any mistake here?
You need to store menu result in one variable like below :
And used json_decode function for convert your json data into array than you can get your menu data through loop.