I need to create a dynamic menu where it creates the hierarchy according to IdMenuPai but unfortunately I can only list without hierarchy, could anyone help me?
function montaMenuFilho($menu) {
echo '<ul class="dropdown-menu pull-left">';
foreach ($menu as $item) {
if(!empty($item->x )) {
echo '<li class="dropdown-submenu">
<a href="#">
<i class="icon-puzzle"></i>'.$item->Descricao.'</a>';
echo montaMenuFilho($item->Home);
echo '</li>';
} else {
if ($item->IdMenu == '27') {
echo '<li class=""><a href="'.$item->Url.'" title="Necessário logar na ferramenta Power BI.">'.$item->Descricao.'</a></li>';
} elseif ($item->IdMenu == '47') {
echo '<li class=""><a href="'.$item->Url.'" title="Apenas para acompanhamento da entrada de recursos.">'.$item->Descricao.'</a></li>';
} elseif ($item->IdMenu == '45') {
echo '<li class=""><a href="'.$item->Url.'" title="Painel em validação">'.$item->Descricao.'</a></li>';
} elseif ($item->IdMenu == '11' || $item->IdMenu == '23' || $item->IdMenu == '16' || $item->IdMenu == '17' || $item->IdMenu == '19' || $item->IdMenu == '12' || $item->IdMenu == '26') {
echo '<li class=""><a target="_blank" href="'.$item->Url.'">'.$item->Descricao.'</a></li>';
} else {
echo '<li class=""><a href="'.$item->Url.'">'.$item->Descricao.'</a></li>';
}
}
}
echo '</ul>';
}
?>
<ul class="nav navbar-nav">
<li class="">
<a href="http://10.31.40.74/novahome/">Home</a>
</li>
<?php
foreach ($menu as $item) {
if(!empty($item->Home)) {
echo '<li class="menu-dropdown classic-menu-dropdown">
<a data-hover="megamenu-dropdown" data-toggle="dropdown">
'.$item->Descricao.'<i class="fa fa-angle-down"></i>
</a>';
echo montaMenuFilho($item);
echo '</li>';
} else {
echo '<li class=""><a href="'.$item->Url.'">'.$item->Descricao.'</a></li>';
}
}
?>
</ul>