caffeinated / menus

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

Sample implementation should use active link detection #63

Open gbrock opened 9 years ago

gbrock commented 9 years ago

Here's my alteration to the Bootstrap 3 sample code for items.blade.php from the wiki (not the cleanest, I know, but it works):

<ul class="{{ $class or 'nav nav-tabs' }}">
@foreach($items as $item)
    <?php if($item->hasChildren()) { $item->attribute('class', $item->attribute('class') . ' dropdown'); } ?>
    <li {!! $item->attributes() !!}>
        @if($item->link) <a @if($item->hasChildren()) class="dropdown-toggle" data-toggle="dropdown" @endif href="{{ $item->url() }}">
            {!! $item->title !!}
            @if($item->hasChildren()) <b class="caret"></b> @endif
        </a>
        @else
            {{$item->title}}
        @endif
        @if($item->hasChildren())
            <ul class="{{ $submenu_class or 'dropdown-menu' }})">
                @foreach($item->children() as $child)
                    <li><a href="{{ $child->url() }}">{{ $child->title }}</a></li>
                @endforeach
            </ul>
        @endif
    </li>
    @if($item->divider)
        <li{{\HTML::attributes($item->divider)}}></li>
    @endif
@endforeach
</ul>
vedmant commented 9 years ago

+1