caffeinated / menus

:pushpin: Menu generator package for the Laravel framework
https://caffeinatedpackages.com
132 stars 59 forks source link

divide() in sub items #65

Open vedmant opened 9 years ago

vedmant commented 9 years ago

Here is a bug I think, when I try to add divide() between sub items http://screencast.com/t/uKugE0SmG4O it appears not inside dropdown but at top level menu http://screencast.com/t/5b2LXRwLF05s

johnhearfield commented 7 years ago

Have you tried adding this in your menu items @foreach($item->children() as $child) loop, like this:

@foreach($items as $item)
        ...
            @if($item->hasChildren())
                <ul class="dropdown-menu" role="menu">
                    @foreach($item->children() as $child)
                        <li>
                            <a href="{{ $child->url() }}{!! $child->attribute('query') !!}">
                                {{ $child->title }}
                            </a>
                        </li>
                        @if ($child->divider)
                            <li {{ \Html::attributes($child->divider) }}></li>
                        @endif
                    @endforeach
                </ul>
            @endif
        ...
@endforeach

The code for when making the submenu:

$dropdown = $menu->add('Dropdown');
$dropdown->add('First Item', ['routes' => 'route.index']);
$dropdown->add('Second Item', ['routes' => 'route.index'])->divide();
$dropdown->add('Action 1, ['routes' => 'route.index'])->divide();