kongondo Posted November 19, 2018 Author Posted November 19, 2018 44 minutes ago, Jozsef said: data protected => array () Hmm. This says your menu is empty. What about this one on line # 105? // on line #105 d($rawMenuItems,'raw menu items');
Jozsef Posted November 19, 2018 Posted November 19, 2018 That has no output at all. I'm very curious what is that, I must overlook something.
kongondo Posted November 20, 2018 Author Posted November 20, 2018 (edited) 35 minutes ago, Jozsef said: That has no output at all. No output meaning nothing appears on screen or no output meaning Tracy says the array is empty? If the former, it means the condition on line #96 is met, meaning the menu is cached (Menu Builder cache). Did you cache the menu? Even in that case, a menu should be built from cache (unless it got deleted by mistake?). Try this on line #100 please: d($menu, 'Cached menu'); Does it return anything? Edited November 20, 2018 by kongondo
Jozsef Posted November 20, 2018 Posted November 20, 2018 That also returns nothing. That is, no output appears on screen from Tracy.
kongondo Posted November 20, 2018 Author Posted November 20, 2018 That's strange. I'm not sure where the items are getting lost. Btw, my Tracy calls should have been bd() rather than d(). Please try bd() in the previous two as well as this on line 86: bd($menuItems); With the bd calls, have a look in the Tracy bar. Is the site online? If I could get a temporary access, I could have a quick look.
Jozsef Posted November 20, 2018 Posted November 20, 2018 It's not live, unfortunately. If I do a print_r($menuItems) in line 86, the output is ' main_menu' instead of an array. Interestingly, there's a space before the name of the menu, I'm not sure if it's important. I'll try to upload it to the server later today.
kongondo Posted November 20, 2018 Author Posted November 20, 2018 (edited) 22 minutes ago, Jozsef said: there's a space before the name of the menu, That's it! If you are logged in as superuser MB should have thrown an error. If not logged in or for non superusers, it will fail silently. Are you logged in as superuser? Try remove the space after that and see if it works. Edited November 20, 2018 by kongondo
Jozsef Posted November 20, 2018 Posted November 20, 2018 But that's the thing, there's no space in the menu name anywhere so I don't know where it came from. I sent you a PM with login details.
Jozsef Posted November 20, 2018 Posted November 20, 2018 Solved: It turned out I had no template file for any of the pages in the menu and the module checks if pages are viewable. Since non of the pages were viewable, menuItems returned an empty array. Thanks @kongondo for the help and pointing me to the right direction. All is well now.
Jozsef Posted November 24, 2018 Posted November 24, 2018 I can't see an option to apply classes on the link itself, on the <a> tag. When using Bootstrap, links must have the nav-link class. Did I miss something? What workaround can I use without messing with the module code? The module is working great, this is really the only thing I missed.
kongondo Posted November 24, 2018 Author Posted November 24, 2018 (edited) 2 hours ago, Jozsef said: I can't see an option to apply classes on the link itself, on the <a> tag. It is not possible. 2 hours ago, Jozsef said: When using Bootstrap, links must have the nav-link class. Did I miss something? What workaround can I use without messing with the module code? For such custom requirements, we suggest use of the method getMenuItems(). It gives you total freedom. Have a read here and see these examples. You'll need to do a bit of custom work. Shout if you need help. Edited November 24, 2018 by kongondo 2
Jozsef Posted November 26, 2018 Posted November 26, 2018 Will do, thanks. I don't know why I didn't think of that earlier. ?
derelektrischemoench Posted January 5, 2019 Posted January 5, 2019 HI guys, I'm using twig for my frontend and I'm trying to pass $options to the menu for rendering. For some reason I can't achieve what I want, as I seem unable to pass associative arrays to the render() call in twig. I'm using markupMenuBuilder to render the menu. I generate it as follows: $menuBuilder = $modules->get('MarkupMenuBuilder'); $options = array( 'has_children_class' => 'has_children', 'current_class' => 'active', 'menu_css_id' => 'main', 'menu_css_class' => 'nav', ); $view->set('options', $options); $view->set('menuBuilder', $menuBuilder); to make menuBuilder accept the options I would have to pass them to the render function in php like this: echo $menu->render('sidenav', $options) I can't get this to work in twig since I don't get how to pass the options to the render function when using twig. Can anyone point me in the right direction plz? Best whishes deM
kongondo Posted January 5, 2019 Author Posted January 5, 2019 This sounds like a Twig issue. I've never used Twig so can't help, unfortunately.
tpr Posted January 5, 2019 Posted January 5, 2019 I guess you should set the rendered html to a twig variable in the php file.
manlio Posted January 16, 2019 Posted January 16, 2019 @kongondo First. Thank you for this great module! I'm writing this in the hope it can help someone. I'm using the latest PW version. Using the module I received this error when switching to a different language from the default one. No menu items found! To solve the issue I went in the admin and find the Menu Builder page (under Admin>Setup) then I edited both the "Menu Builder" page and "mainmenu" page (this a menu that I built in Menu Builder) and set the other language to active. It seems the module doesn't set as active new pages in languages different from default. My PW installation by default set it to false. Hope this helps. Ciao 2
kongondo Posted January 16, 2019 Author Posted January 16, 2019 54 minutes ago, manlio said: It seems the module doesn't set as active new pages in languages different from default. That's correct. Full multi-lingual support has been on my todo list for a long time. Hopefully I'll get some time soon to look into it. 56 minutes ago, manlio said: I'm writing this in the hope it can help someone. Thanks for sharing your workaround with others. 2
csaeum Posted February 10, 2019 Posted February 10, 2019 I have just installed the MenuBuilder and wanted to rebuild a menu as in the standard UIKIT design of PW. How can I get it that the submenus are in a DIV? Can I install it somewhere in the options or in a template? Because by default it is UL => LI => UL => LI AT UIKIT IT IS YES BUT UL => LI => DIV => UL => LI Thank you for your help!
kongondo Posted February 11, 2019 Author Posted February 11, 2019 11 hours ago, csaeum said: How can I get it that the submenus are in a DIV? Have a look these examples: you will need to use getMenuItems() method.
MateThemes Posted February 16, 2019 Posted February 16, 2019 Hello! I like to use the menu builder module. I like the freedom for the website administrator to add and remove easily pages. But if I use the menubuilder with more than one menus on a page i got an error with the language code. It is a multilanguage website. Does anyone have experience with such an error? Thanks for your help! Best greetings Gerald @mate-themes
Zeka Posted February 16, 2019 Posted February 16, 2019 @MateThemes Could you please share your code and the error you are getting? Also, make sure that you are not passing a menu name or title as the first argument of the render method. In ML setup it should be id, an array of menu items or page object. 1
wbmnfktr Posted February 16, 2019 Posted February 16, 2019 Maybe this could help... if it's the same error/behaviour: 1
MateThemes Posted February 17, 2019 Posted February 17, 2019 16 hours ago, wbmnfktr said: Maybe this could help... if it's the same error/behaviour: Thank you very much!!!
MateThemes Posted February 17, 2019 Posted February 17, 2019 (edited) Hello everyone!!! Maybe I am missing something. First I need to say the module works now fine, but as i said, i am missing something. I have following html markup: <div class="uk-navbar-center uk-visible@m"> <!-- Main Menu --> <ul class='uk-navbar-nav'> <li class="uk-active"><a href="/">Home</a></li> <li><a href="/der-schiort/">Schiort</a></li> <li><a href="#">Test</a> <div class='uk-navbar-dropdown'> <ul class='uk-nav uk-navbar-dropdown-nav'> <li><a href="/impressum/">Impressum</a></li> <li><a href="/datenschutz/">Datenschutz</a></li> </ul> </li> </ul> </div> And following Menubuilder Code for the Menu: <?php /** * Builds a nested list (menu items) of a single menu. * * A recursive function to display nested list of menu items. * * @access private * @param Int $parent ID of menu item. * @param Array $menu Object of menu items to display. * @param Int $first Helper variable to designate first menu item. * @return string $out. * */ function buildMenuFromObject($parent = 0, $menu, $first = 0) { if(!is_object($menu)) return; $out = ''; $has_child = false; foreach ($menu as $m) { $newtab = $m->newtab ? " target='_blank'" : ''; // if this menu item is a parent; create the sub-items/child-menu-items if ($m->parentID == $parent) {// if this menu item is a parent; create the inner-items/child-menu-items // if this is the first child if ($has_child === false) { $has_child = true;// This is a parent if ($first == 0){ $out .= "<ul class='uk-navbar-nav'>\n"; $first = 1; } else $out .= "\n<div class='uk-navbar-dropdown'>\n<ul class='uk-nav uk-navbar-dropdown-nav'>\n"; } $class = $m->isCurrent ? ' class="uk-active"' : ''; // a menu item $out .= '<li' . $class . '><a href="' . $m->url . '"' . $newtab . '>' . $m->title; // if menu item has children if ($m->isParent) { $out .= '</a>'; } else $out .= '</a>'; // call function again to generate nested list for sub-menu items belonging to this menu item. $out .= buildMenuFromObject($m->id, $menu, $first); $out .= "</li>\n"; }// end if parent }// end foreach if ($has_child === true) $out .= "</ul>\n"; return $out; } ################################## /* grab menu items using MarkupMenuBuilder */ $mb = $modules->get('MarkupMenuBuilder');// get Menu Builder /* get menu the menu we want (i.e. a menu created and published using ProcessMenuBuilder) */ // we can pass the menu's Page, page ID, title, name or its menu items string to getMenuItems() #$menu = $pages->get(1299);// pass a Page $menu = 1041;// pass an ID #$menu = 'main';// pass a name // passing an array #$jsonStr = $pages->get(1299)->menu_items; #$arrayFromJSON = json_decode($jsonStr, true); #$menu = $arrayFromJSON;// pass an array #$menu = 'Main';// pass a title /* only these 3 options apply to getMenuItems() */ $options = array('default_title'=> 1, 'default_class'=> 'cool_menu_class', 'current_class_level' => 4); /* grab menu items as a WireArray with Menu objects */ $menuItems = $mb->getMenuItems($menu, 2, $options);// called with options and 2nd argument = 2 {return Menu (WireArray object)} #$menuItems = $mb->getMenuItems($menu);// if calling without without options; 2nd argument defaults to 2 ?> <?php // build menu from array (example 1b only) echo buildMenuFromObject(0, $menuItems); ?> How can I close the <div class="uk-navbar-dropdown">? Everything I've tried seems not to work! Thank you very much for your help!!! Edited February 17, 2019 by MateThemes
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now