Closed Fuhrmann closed 12 years ago
Your array looks right, and that's how the plugin worked in the past. To be honest, I think I've only been working with simple menus since I rewrote the plugin a couple weeks ago, so it very well could be a bug that I just haven't noticed yet.
Sorry about that! I'm investigating now what the issue might be and should have an answer for you shortly.
Just to clarify, you're getting all parent items rendered, but only a single (the last) child when there are children?
"Just to clarify, you're getting all parent items rendered, but only a single (the last) child when there are children?"
Yes, exactly! Let's say I have this:
Menu 1 Menu 2 ---- Children 1 ---- Children 2 ---- Children 3 ---- Children 4 ---- Children 5 Menu3
The following is rendered:
Menu 1 Menu 2 ---- Children 5 Menu3
And just to help direct my troubleshooting, are you just using the menu() method of MenuBuilderComponent to define the entire menu, or are you building it from individual pieces?
Thanks!
I'm using this in my AppController:
// Load the menu model
$this->loadModel('Menu');
// The menu array
$menus = $this->Menu->loadSystemMenu();
// Build the menu with the menu plugin
$this->MenuBuilder->menu('main', $menus);
I found the issue, and it's working for me now in my tests with multiple child items.
When I was testing within MenuItem if there was already a child menu, I was checking $children instead of $this->children, so it was re-creating the child menu every time and overwriting any other children.
This should be all fixed now. Let me know your results. Thanks!
That was fast, thanks. I'm going to home now, and ASAP I'll take a look at the updated code.
Thanks!
Hey, Ben.
This is working great now too. Thank you.
No prob, glad to hear. Thanks for helping me squash this one!
Ben, I have this Menu, loaded using a Model:
\app\Model\Menu.php (line 176)
The strange thing is when I tell the plugin to render my menu, only the last children is rendered:
Maybe I'm doing something wrong when populating the menu array, I don't know. But what I'm doing is just getting all the menu list from database and put them in an array.
Thanks.