Menu icon Foundation
Putting MPTT Menu into Dropdown

 

Hello , I am trying to put a MPTT into a dropdown menu.

Here is an array example:

This is the code I am using at the moment:

function array2ul($array) {
    $out = '<ul class="dropdown menu" data-dropdown-menu>';
    foreach ($array as $key => $elem)
        $out .= '<li>' .
            $elem['title'] .
            (is_array($elem['children']) ?
                array2ul($elem['children']) :
                ''
            ) .
            '</li>';
    return $out . '</ul>';
}

According to the docs when the sub menus go in, I need to add a class of only menu.  But I seem unable to create the logic to allow this happen.

 

Any ideas on how to do this ?

 

Thanks

 

dropdownMPTT

 

Hello , I am trying to put a MPTT into a dropdown menu.

Here is an array example:

This is the code I am using at the moment:

function array2ul($array) {
    $out = '<ul class="dropdown menu" data-dropdown-menu>';
    foreach ($array as $key => $elem)
        $out .= '<li>' .
            $elem['title'] .
            (is_array($elem['children']) ?
                array2ul($elem['children']) :
                ''
            ) .
            '</li>';
    return $out . '</ul>';
}

According to the docs when the sub menus go in, I need to add a class of only menu.  But I seem unable to create the logic to allow this happen.

 

Any ideas on how to do this ?

 

Thanks