4
I have a menu (vertical) that works as acordion, this in turn, need to open the "children" limitlessly (my problem to be solved, and can not), since it will be a menu for a store.
As follows:
-PARENT CATEGORY
- CATEGORIA FILHO
- CATEGORIA FILHO
- CATEGORIA PAI
- CATEGORIA PAI
- CATEGORIA FILHO
- CATEGORIA FILHO
-CATEGORIA PAI
- CATEGORIA FILHO
- CATEGORIA FILHO
And to the auto and onward...
However, I’m not accomplishing such a feat...
So if you could, you could give me a hand in this situation?
Already I am immensely grateful.
This is my JS code (taken from the NET):
// Evento de clique do elemento: ul#menu li.parent > a
$('ul#menu li.parent > a').click(function() {
// Expande ou retrai o elemento ul.sub-menu dentro do elemento pai (ul#menu li.parent)
$('ul.sub-menu', $(this).parent()).slideToggle('fast', function() {
// Depois de expandir ou retrair, troca a classe 'aberto' do <a> clicado
$(this).parent().toggleClass('aberto');
});
return false;
});
PHP:
public static function getHtmlMenu($menu){
$return = '';
foreach($menu as $m){
$class = ($m['NIVEL'] == '0') ? 'parent' : '';
$return .= '<li class="'.$class.'"><a href="'.SITEURL.'produtos/'.$m['ID'].'/'.$m['ALIAS'].'" title="'.$m['TITULO'].'">'.$m['TITULO'].'</a>'.PHP_EOL;
if(sizeof($m['SUB']) > 0){
$return .= '<ul class="sub-menu">'.PHP_EOL;
$return .= self::getHtmlMenu($m['SUB']);
$return .= '</ul>'.PHP_EOL;
}
$return .= '</li>'.PHP_EOL;
}
return $return;
}
CSS:
.parent > a {
background: url("../images/menul.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
color: #052754;
display: block;
font-size: 10.3px;
font-weight: bold;
height: 21px;
padding: 5px 5px 0;
text-transform: uppercase;
}
ul ul {
display: none;
}
.sub-menu > li {
background: none repeat scroll 0 0 #FFFFFF;
height: 21px;
overflow: hidden;
padding: 1px 0;
width: 243px !important;
}
.sub-menu a {
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid #CCCCCC;
color: #052754;
display: block;
font-size: 12px;
padding: 3px 0 3px 10px;
text-transform: uppercase;
}
I really forgot to report my problem. What happens is that this menu only goes down to the 2nd level, and I would like it to be "infinite". That is, if there are sub-menus it still works the JS and CSS.
As for the order of the list, it is right... Running inside PHP is the following:
<ul><li><!--repete o <ul> anterior caso tenha novos "subs"--></li></ul>
I made a fiddle for anyone who wants to find the problem.
– Gustavo Rodrigues
Is that something you want? http://doforneiro.com.br/lista1.html
– Joao Paulo
look here: https://forum.imasters.com.br/topic/378975-menu-em-php-com-mysql/
– Ivan Ferrer