Ok, strange titel, i know.
But it does say kinda what my problem is.
I'm calling the menu by show_menu2
My menu is a dropdown with only 1 sublevel.
In short, this is the basic:
<ul>
<li></li>
<li>
<ul>
<li></li>
</ul>
</li>
<li></li>
<li></li>
</ul>
I use the default WB classes for the top menu.
But to make my menu work properly, i've added <span> tags in first menu items.
In the submenu, the menu items shouldn't have a <span>.
A full example of the output right now on the website:
<ul class="menu-top">
<li class="menu-current menu-first"><a href="#" target="_top"><span>Home</span></a></li>
<li class="menu-sibling"><a href="#" target="_top"><span>Wonen</span></a></li>
<li class="menu-sibling"><a href="#" target="_top"><span>Ontwerp</span></a></li>
<li class="menu-expand menu-sibling"><a href="#" target="_top"><span>Tuinen</span></a>
<ul class="">
<li class="menu-first"><a href="#" target="_top"><span>Grote tuinen</span></a></li>
<li class=""><a href="#" target="_top"><span>Kleine tuinen</span></a></li>
<li class=""><a href="#" target="_top"><span>Landschapstuinen</span></a></li>
</ul>
</li>
<li class="menu-sibling"><a href="#" target="_top"><span>Grondwerk</span></a></li>
<li class="menu-sibling"><a href="#" target="_top"><span>Beplanting</span></a></li>
<li class="menu-sibling"><a href="#" target="_top"><span>Contact</span></a></li>
<li class="menu-sibling menu-last"><a href="#" target="_top"><span>Tuin Leasen</span></a></li>
</ul>
The menu should be like the following example.
The difference is, no <span> at the links in the submenu.
And below the latest List, in the submenu, there is an extra <li>
I need this for a correct way of styling the dropdown.
<ul class="menu-top">
<li class="menu-current menu-first"><a href="#" target="_top">Home</a></li>
<li class="menu-sibling"><a href="#" target="_top">Wonen</a></li>
<li class="menu-sibling"><a href="#" target="_top">Ontwerp</a></li>
<li class="menu-expand menu-sibling"><a href="#" target="_top">Tuinen</a>
<ul class="">
<li class="menu-first"><a href="#" target="_top">Grote tuinen</a></li>
<li class=""><a href="#" target="_top">Kleine tuinen</a></li>
<li class="menu-last"><a href="#" target="_top">Tuin Leasen</a></li>
<li class="ul_bottom"></li>
</ul>
</li>
<li class="menu-sibling"><a href="#" target="_top">Grondwerk</a></li>
<li class="menu-sibling"><a href="#" target="_top">Beplanting</a></li>
<li class="menu-sibling"><a href="#" target="_top">Contact</a></li>
<li class="menu-sibling menu-last"><a href="#" target="_top">Tuin Leasen</a></li>
</ul>
Now i am playing allmost all night with a lot of possibilities the show_menu2 offers.
I tried and customized many options on which is given on this page (http://code.jellycan.com/sm2test/). But i can't get it work like i want it to be.
Right now i am using the show_menu2 code below.
How can i change my code to leave the class on the first <ul> and get rid of the empty class on the second <ul>.
In the first <li><a><span> list i have a span, but in the submenu the span should be gone and below the menu-last, i need an extra <li class="ul_bottom"></li>.
How on earth can i have this by customizing the below menu code... i'm out of options... maybe it's not possible at all. I don't know.
<?php show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL|SM2_PRETTY, '[li][a]<span>[page_title]</span></a>', false, false, false); ?>
Thank you.
Dave
Hello Dave,
you may find sm2's if/else conditional useful for this.
Try the following (extracted to better illustrate the if/else condition) code:
<?php
$start_level = 1;
show_menu2(0,
SM2_ROOT,
SM2_ALL,
SM2_ALL|SM2_PRETTY,
"[li][a]
[if(level==".$start_level."){
<span>[page_title]</span>
} else {
[page_title]
}]</a>",
false,
false,
false);
?>
The variable $start_level should be changed to what your environment needs.
In the template you may use (of course) the "squeezed" format:
<?php show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL|SM2_PRETTY, "[li][a][if(level==1){<span>x[page_title]</span>} else {[page_title]}]</a>",false,false,false);?>
Nice greetings,
Stefek
What a relief to see some positive changes. Really.
So, that means your code worked, for 80% :)
It else if was supposed to be switched like:
<?php
$start_level = 1;
show_menu2(0,
SM2_ROOT,
SM2_ALL,
SM2_ALL|SM2_PRETTY,
"[li][a]
[if(level==".$start_level."){
[page_title]
} else {
<span>[page_title]</span>
}]</a>",
false,
false,
false);
?>
You know, i try to understand the logic in it. But i just can't see the reasons why the 'false' should be 'there' and if the code must be in a specific order. I just can't see it. Maybe it's because the late hour right now, i don't know.
I tried to replace some 'false,' with the extra <li class""><li> below the menu-last item.
But it's just not happening for me. As a matter of fact, it really annoying and freaks me out right now :lol:
I think i should catch some sleep and try tomorrow again.
But...!! You learned me again something i didn't found yet on the forum Stefek. Thanks!
Hello Dave,
best thing to do is reading the manual.
You will find all the info and hints there.
In fact, sm2 was the first time I came in touch with "programming".
I don't know about your php skills, but if you still have questions after reading the manual, just let me know in this thread.
Regards,
Stefek