Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to achieve multilevel menus? #239

Open
xmontero opened this issue May 10, 2018 · 5 comments
Open

How to achieve multilevel menus? #239

xmontero opened this issue May 10, 2018 · 5 comments

Comments

@xmontero
Copy link

In the AdminLte demo here https://adminlte.io/themes/AdminLTE/index2.html I can see multilevel menus.

Instead, when I try to do them in avanzu, I can't display them:

If I do this (only 1 level):

$level1 = new MenuItemModel( 'level1', 'Level 1', 'form_submission_bulk_display_change_state_form', [], 'fa fa-star' );

$menuItems[ 'tests' ]->addChild( $level1 );

I get this:

image

If I do this (2 levels), I'd expect that the menu "Level 1" contains a caret to open a submenu named "Level 2".

$level1 = new MenuItemModel( 'level1', 'Level 1', 'form_submission_bulk_display_change_state_form', [], 'fa fa-star' );
$level2 = new MenuItemModel( 'level2', 'Level 2', 'form_submission_bulk_display_change_state_form', [], 'fa fa-star' );
$level1->addChild( $level2 );

$menuItems[ 'tests' ]->addChild( $level1 );

Instead, I get this:

image

And there's no toggle there to open/close, as it'd be expected according to the AdminLte demo:

image

Question: How can I code submenus in a multilevel menu?

Component Version
Symfony version Symfony 3.3.10
AdminThemeBundle 1.3.10
Operating System Ubuntu 16.04 LTS
@shakaran shakaran self-assigned this May 16, 2018
@shakaran shakaran added this to the Version 2.0 Stable milestone May 16, 2018
@xmontero
Copy link
Author

Will this be also available in 1.3?

@shakaran
Copy link
Collaborator

shakaran commented May 21, 2018

@xmontero do you need it? Maybe it could be backported. But the idea is get rid soon of 1.3.x series and use as soon as possible 2.x and 3.x in future

@xmontero
Copy link
Author

xmontero commented May 21, 2018

Well, I guess that changing the major means it breaks compatibility. I have a huge dependency on the bundle and I'm not ready to afford the resources to "migrate from 1.3 to 2.0" if it is "very different" to consume.

Breaking my admin panel say during 1 week could kill my business.

Is there any documentation on "migrating from 1.3 to 2.0". If it's "easy" I can try to move to 2.0.

As an example, large projects migrating from symfony 1 to 2 took 1 to 2 years of rewriting, while porting from symfony 2 to 3 was a matter of changing some directories and done. With this, I mean it's very "unpredictable" how much time it'll take to tackle a major-version change, unless it's clear where to touch. Symfony has had this in consideration and made any other "major" migration much simpler. Passing from 3 to 4 seems "trivial".

What's the complexity of moving avanzu from 1.3 to 2.0? Any documentation on that?

@danielroehrig-mm
Copy link
Contributor

@xmontero I implemented the feature by overwriting the macros.html.twigfile. It's been a while and I'm not sure if this is the right way of doing this but here you go
Just copy the macros.html.twigfile into app/Resources/AvanzuAdminThemeBundle/views/layout/macros.html.twig and replace the menu_itemmacro. Hope this helps.

@shakaran
Copy link
Collaborator

shakaran commented Aug 5, 2021

@xmontero please confirm if this is working for you:

// Declare a empty array
$menuItems = [];

// Declare the MenuItemModels
$level1 = new MenuItemModel( 'level1', 'Level 1', 'form_submission_bulk_display_change_state_form', [], 'fa fa-star' );
$level2 = new MenuItemModel( 'level2', 'Level 2', 'form_submission_bulk_display_change_state_form', [], 'fa fa-star' );

// Add the child
$level1->addChild( $level2 );

// Add as item in menu.
$menuItems = [$level1];

Check that you don't have duplicated identifiers (there are a bug with collision name identifiers)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants