nWidart / laravel-menus

Laravel Menu Management
MIT License
167 stars 104 forks source link

Possible to make mega menu with it? #15

Open a-h-abid opened 6 years ago

a-h-abid commented 6 years ago

Is it possible to make Mega Menu with this package???

noxify commented 6 years ago

Why not?

My idea for this is to use the dropdown element which will be used to group the links inside the mega menu.

a-h-abid commented 6 years ago

@noxify I guess I need to do some customize in a Custom Presenter. But it is not clear to me what to do. I mean, how can I tell it that I want this dropdown menu Mega Menu and this other dropdown one Usual Menu?

noxify commented 6 years ago

I guess I need to do some customize in a Custom Presenter.

You're right.

But it is not clear to me what to do. I mean, how can I tell it that I want this dropdown menu Mega Menu and this other dropdown one Usual Menu?

In my idea, i have for example a mega menu with 4 columns. Based on the documentation, the menu definition looks something like this: ( https://nwidart.com/laravel-menus/v1/introduction )

Menu::create('megamenu', function($menu) {
    $menu->dropdown('Column 1', function ($sub) {
        $sub->header('First Column Headline');
        $sub->url('#', 'Link 1');
        $sub->url('#', 'Link 1');
        $sub->url('#', 'Link 1');
    }, 1);

    $menu->dropdown('Column 2', function ($sub) {
        $sub->header('Second Column Headline');
        $sub->url('#', 'Link 2');
        $sub->url('#', 'Link 2');
        $sub->url('#', 'Link 2');
    }, 2);

    $menu->dropdown('Column 3', function ($sub) {
        $sub->header('Third Column Headline');
        $sub->url('#', 'Link 3');
        $sub->url('#', 'Link 3');
        $sub->url('#', 'Link 3');
    }, 3);

    $menu->dropdown('Column 4', function ($sub) {
        $sub->header('Fourth Column Headline');
        $sub->url('#', 'Link 4');
        $sub->url('#', 'Link 4');
        $sub->url('#', 'Link 4');
    }, 4);
});

Now you "only" have to define your own presenter which returns the correct html for your mega menu.

Alternative you can define different menus instead of one menu. I think this is easier for the first run, but makes it a bit unflexible (for me), because you can't use the order functionality (as you can see in the example above).