Author Topic: Open submenu after clicking main menu  (Read 480 times)

Offline henri

  • Posts: 134
Open submenu after clicking main menu
« on: March 10, 2018, 02:34:02 PM »
Is there a way to change the code below so that the submenu only appears after a mouse click on the main menu item.

<? php
show_menu2 (
0, SM2_ROOT, SM2_ALL, SM2_ALL,
'
  • [if (class == menu-expand && level == 0) {<a> [menu_title] </a>} else {<a href="[url]"> [menu_title] </a> }] ',' </ li> ',
    false,
    false,
    false,
    '<ul class = "nav-menu" id = "main-navigation">'
    );
    ?>

Offline dbs

  • Betatester
  • **
  • Posts: 7788
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: Open submenu after clicking main menu
« Reply #1 on: March 10, 2018, 03:36:21 PM »
Hi, for code please use in the editor the code button #
Have you tried TRIM?
Code: [Select]
<?php
show_menu2 
(
    
0SM2_ROOTSM2_ALLSM2_TRIM,
    
'[if (class == menu-expand && level == 0) {<a> [menu_title] </a>} else {<a href="[url]"> [menu_title] </a> }] ',' </ li> ',
    
false,
    
false,
    
false,
    
'<ul class = "nav-menu" id = "main-navigation">'
    
);

If this not work, tell more about what a menu you have and want.

Offline jacobi22

  • Posts: 5683
  • Gender: Male
  • Support also via PM or EMail
    • Jacobi22
Re: Open submenu after clicking main menu
« Reply #2 on: March 10, 2018, 04:42:41 PM »
<?php
show_menu2 
(
    
0SM2_ROOTSM2_ALLSM2_TRIM,
    
'[if (class == menu-expand && level == 0) {<a> [menu_title] </a>} else {<a href="[url]"> [menu_title] </a> }] ',' </ li> ',
    
false,
    
false,
    
false,
    
'<ul class = "nav-menu" id = "main-navigation">'
    
);


a-tag without href-attribute is invalid, use
Code: [Select]
<a href="#">[menu_title]</a>instead of the simple <a>
Quote
if (class == menu-expand && level == 0)

means: this code behind my quote works only, if an link has at minimum one child (condition: class == menu-expand=
if you need it for all links in the first level of the visible menu, use the level-condition only

HINT: level 0 (zero) is the root of WB and this example works only, if you want to display this root pages (specially for single language pages). Be sure, that you use your favorite level in the condition

Probleme sind da, um sie zu lösen, nicht, um nach Ausreden zu suchen.

Offline henri

  • Posts: 134
Re: Open submenu after clicking main menu
« Reply #3 on: March 10, 2018, 08:33:15 PM »
Different combinations tried.
The combination below works best but if I use the mouse on the item in the main menu, then the submenu appears immediately.
The submenu should appear after clicking on item in main menu.

<?php
show_menu2(
0,SM2_ROOT, SM2_ALL, SM2_ALL,
'
  • [if (condition:class==menu-expand && level==0) {<a href>[menu_title]</a>} else {<a href="[url]"> [menu_title] </a> }] ',' </ li> ',
    false,
    false,
    false,
    '<ul class="nav-menu" id="main-navigation">'
    );                   
    ?>

    If I use the code below, no submenu will appear after a mouse click on the main menu item.
    If I set the value of level == 0 to 1, the submenu will appear but in the main menu the item that I click with the mouse will also open. What is not the intention.

    <?php
    show_menu2(
    0,SM2_ROOT, SM2_ALL, SM2_TRIM,
    '
    • [if (condition:class==menu-expand && level==0) {<a href="#">[menu_title]</a>} else {<a href="[url]"> [menu_title] </a> }] ',' </ li> ',
      false,
      false,
      false,
      '<ul class="nav-menu" id="main-navigation">'
      );                   
      ?>

 

postern-length