WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Templates, Menus & Design => Topic started by: neu1886 on June 06, 2017, 01:12:11 AM

Title: Show_Menu2 - everytime the same s*** :D
Post by: neu1886 on June 06, 2017, 01:12:11 AM
Hi everyone,

today i have a simple question but i can't find a solution. I have a main menu which only shows the level 0 items (top level). Clear, every top level page could have n..* subpages. If a top level page is selected, i want an output (second menu) like this

Code: [Select]
HOME   NEWS   > EVENTS < (Main Menu)

--Menu 2--
EVENT 1
> EVENT 2 <

I use this code for Menu 2:

Code: [Select]
show_menu2(0, SM2_ROOT+1, SM2_START, SM2_ALL | SM2_PRETTY);
But if i select EVENT 1...EVENT 2 etc. the menu vanish. But i want to have the Menu for each Subpage of EVENTS. How to realize this?

Thanks and sorry for the bad english!
Title: Re: Show_Menu2 - everytime the same s*** :D
Post by: dbs on June 06, 2017, 08:16:25 AM
Hi, here my bad english answer ( there is also a german forum  :wink: ).
You should show us the show_menu2 codes for main menu and for the submenu.
Title: Re: Show_Menu2 - everytime the same s*** :D
Post by: neu1886 on June 06, 2017, 11:44:10 AM
Code for the Main Menu:

Code: [Select]
$openItem = '<li[if(class=menu-current||class=menu-parent){ class="active"}]><a href="[url]"><span data-hover="Home">[menu_title]</span></a>';

show_menu2(
$aMenu          = 0,
$aStart         = SM2_ROOT,
$aMaxLevel      = SM2_START,
$aOptions       = SM2_ALL | SM_PRETTY,
$aItemOpen      = $openItem,
$aItemClose     = '</li>',
$aMenuOpen      = '<ul class="nav navbar-nav">',
$aMenuClose     = '</ul>',
$aTopItemOpen   = false,
$aTopMenuOpen   = false
)

Code for the Submenu:

Code: [Select]
function hasSubmenu() {
$childs = show_menu2(0, SM2_CURR+1, SM2_START, SM2_BUFFER|SM2_ALL|SM2_CURRTREE);
return (!empty($childs)) ? true : false;
}

if(hasSubmenu()) {
$menuItem = '<li[if(class=menu-current||class=menu-parent){ class="active"}]><a href="[url]"><i class="g-mr-10 fa tab__fa fa-arrow-right"></i> [menu_title]</a>';

show_menu2(
$aMenu          = 0,
$aStart         = SM2_ROOT+1,
$aMaxLevel      = SM2_START,
$aOptions       = SM2_ALL | SM_PRETTY,
$aItemOpen      = $menuItem,
$aItemClose     = '</li>',
$aMenuOpen      = '<ul class="nav nav-pills nav-stacked">',
$aMenuClose     = '</ul>',
$aTopItemOpen   = false,
$aTopMenuOpen   = false
);
}

It looks like hasSubmenu doesn't work correctly.  :-(
Title: Re: Show_Menu2 - everytime the same s*** :D
Post by: dbs on June 06, 2017, 02:46:04 PM
You can test in
Code: [Select]
if(hasSubmenu()) { ...
...
$aStart         = SM2_CURR+1,
Title: Re: Show_Menu2 - everytime the same s*** :D
Post by: dbs on June 06, 2017, 06:21:26 PM
and look here
Code: [Select]
$aOptions       = SM2_ALL | SM_PRETTY,should be
Code: [Select]
$aOptions       = SM2_ALL | SM2_PRETTY,