WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • Different classes in <ul> and no span in <li> submenu/dropdown
  • Print
Pages: [1]   Go Down

Author Topic: Different classes in <ul> and no span in <li> submenu/dropdown  (Read 4738 times)

Offline D72

  • Posts: 295
  • Gender: Male
Different classes in <ul> and no span in <li> submenu/dropdown
« on: October 30, 2010, 12:28:17 AM »
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:
Code: [Select]
<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:
Code: [Select]
<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.
Code: [Select]
<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. 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.
Code: [Select]
<?php show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL|SM2_PRETTY, &#39;[li][a]<span>[page_title]</span></a>&#39;, false, false, false); ?>
Thank you.
Dave
Logged

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Different classes in <ul> and no span in <li> submenu/dropdown
« Reply #1 on: October 30, 2010, 12:51:54 AM »
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:
Code: [Select]
<?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:

Code: (change the level here) [Select]
<?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
Logged
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline D72

  • Posts: 295
  • Gender: Male
Re: Different classes in <ul> and no span in <li> submenu/dropdown
« Reply #2 on: October 30, 2010, 01:15:03 AM »
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:
Code: [Select]
<?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!
Logged

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Different classes in <ul> and no span in <li> submenu/dropdown
« Reply #3 on: October 30, 2010, 01:32:58 AM »
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
Logged
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • Different classes in <ul> and no span in <li> submenu/dropdown
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2