WebsiteBaker Community Forum

WebsiteBaker Support (2.11.x) => General Help & Support => Topic started by: henri on March 10, 2018, 02:34:02 PM

Title: Open submenu after clicking main menu
Post by: henri 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,
'
Title: Re: Open submenu after clicking main menu
Post by: dbs 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.
Title: Re: Open submenu after clicking main menu
Post by: Gast on March 10, 2018, 04:42:41 PM
<?php
show_menu2 (
    0, SM2_ROOT, SM2_ALL, SM2_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

Title: Re: Open submenu after clicking main menu
Post by: henri 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,
'