Skip to content

How to achieve multilevel menus? #239

Open

Description

@xmontero

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

Activity

  1. self-assigned this
    on May 16, 2018
  2. added this to the Version 2.0 Stable milestone on May 16, 2018
  3. xmontero commented on May 21, 2018

    @xmontero
    Author

    Will this be also available in 1.3?

  4. shakaran commented on May 21, 2018

    @shakaran
    Collaborator

    @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

  5. xmontero commented on May 21, 2018

    @xmontero
    Author

    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?

  6. danielroehrig-mm commented on Jun 15, 2018

    @danielroehrig-mm
    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.

  7. shakaran commented on Aug 5, 2021

    @shakaran
    Collaborator

    @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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions