We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Submenu in Vokuro

Hi,

Totaly new to Phalcon and trying to use Vokuro, I love how simple its menu system is and want to craete a submenu but dont know how, would anyone be able to guide me please. below is the code I believe I need to change:

{%- set menus = [ 'Home': null, 'Users': 'users',
'Profiles': 'profiles', 'Permissions': 'permissions', ] -%}

Thank you in advance

You could try using a multidimensional array to define the submenus. Like this:

{%- set menus = [
    'Home': 'index',
    'About': ['about', [
        'SubItem1': 'link1',
        'SubItem2': 'link2'
    ]]
] -%}

And then print the menu items like this:

{%- macro render_menu_items(menu_items) %}
    {% for key, value in menu_items %}
        {% if value is type('array') %}
            <li>
                {{ link_to(value[0], key) }}
                <ul class="nav-submenu">
                    {{ render_menu_items(value[1]) }}
                </ul>
            </li>
        {% else %}
            <li>{{ link_to(value, key) }}</li>
        {% endif %}
    {% endfor %}
{%- endmacro %}

{{ render_menu_items(menus) }}

Then of course you have to handle the show/hide functionality of the submenu, either with CSS or Javascript.

Perfect thank you