Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 12:41:16 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155537 Posts in 21712 Topics by 7736 Members
Latest Member: chris85
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Different classes in <ul> and no span in <li> submenu/dropdown  (Read 878 times)
D72

Offline Offline

Posts: 253


« on: October 29, 2010, 11:28:17 PM »

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:
<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:
<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:
<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:
<?php show_menu2(0SM2_ROOTSM2_ALLSM2_ALL|SM2_PRETTY'[li][a]<span>[page_title]</span></a>'falsefalsefalse); ?>

Thank you.
Dave
Logged
Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4884



« Reply #1 on: October 29, 2010, 11:51:54 PM »

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:
<?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)
<?php show_menu2(0SM2_ROOTSM2_ALLSM2_ALL|SM2_PRETTY"[li][a][if(level==1){<span>x[page_title]</span>} else {[page_title]}]</a>",false,false,false);?>


Nice greetings,
Stefek
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
D72

Offline Offline

Posts: 253


« Reply #2 on: October 30, 2010, 12:15:03 AM »

What a relief to see some positive changes. Really.
So, that means your code worked, for 80% Smiley
It else if was supposed to be switched like:
Code:
<?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  cheesy
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
Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4884



« Reply #3 on: October 30, 2010, 12: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

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!