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

In case you are using bootstrap 5 (currently in beta) you need to set the data-toggle-attribute option from data-toggle to data-bs-toggle in your config/laravel-menu/settings.php. #302

Open
mtkumar82 opened this issue Feb 10, 2023 · 1 comment

Comments

@mtkumar82
Copy link

In case you are using bootstrap 5 (currently in beta) you need to set the data-toggle-attribute option from data-toggle to data-bs-toggle in your config/laravel-menu/settings.php.

I tried to change the value from
'data-toggle-attribute'=>'data-bs-toggle' in same file metioned above, But its not getting changed there.

return array(
'default' => array(
'auto_activate' => true,
'activate_parents' => true,
'active_class' => 'active',
'restful' => false,
'cascade_data' => true,
'rest_base' => '', // string|array
'active_element' => 'item', // item|link
'data_toggle_attribute' => 'data-bs-toggle',
),
);

Can you please help me what changes I need to do more for this one?

Thanks

@reidsneo
Copy link

reidsneo commented Apr 6, 2023

Hi, that was correct but if you use config to draw the menu, can you give snip how you draw the menu?

I use following code to draw menu for bootstrap 5.2.3 it work out of the box

menu.blade.php

@foreach($items as $item)
  <li class="nav-item">
    <a class="nav-link @if(!$item->hasChildren()) menu-link @endif {{ $item->active ? 'active' : '' }}"
    @if($item->hasChildren()) data-bs-toggle="collapse" role="button" @endif
    @if(Str::contains($item->url(),"#")) href="#{!! explode("#",$item->url())[1] !!}" aria-controls="{!! explode("#",$item->url())[1] !!}" @else href="{!! $item->url() !!}" aria-controls="" @endif>
    @if($item->icon != null) <i class="{!! $item->icon !!}"></i> @endif
    @if($item->hasParent()) {!! $item->caption !!} @else <span>{!! $item->caption !!}</span>  @endif</a>
        @if($item->hasChildren())
        <div class="collapse menu-dropdown {{ $item->active ? 'show' : '' }}" @if(Str::contains($item->url(),"#")) id="{!! explode("#",$item->url())[1] !!}" @endif>
            <ul class="nav nav-sm flex-column">
                @include('theme::views.backend.menu', ['items' => $item->children()])
            </ul>
        @endif
    </li>
@endforeach

in main layout you need to call the menu.blade.php

<ul class="navbar-nav" id="navbar-nav">
            <li class="menu-title"><span></span></li>
            @include('theme::views.backend.menu', ['items' => $MenuBackend->roots()])
            </ul>

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

No branches or pull requests

2 participants