Tim Kruger
Tim Kruger

Reputation: 897

Setting active link using Laravel 5.2 and SimpleStart WrapBootstrap template

I wanted to find out what the best approach would be to set the active link for menu items as well as child menu items in Laravel 5.2.* using the SimpleStart WrapBootstrap template found here: https://wrapbootstrap.com/theme/simple-start-WB03148JJ, and here is the content of my nav.blade.php file:

<div class="span6">
    <div class="pull-right">
        <ul class="nav nav-pills ddmenu">
            <li class="active dropdown"><a href="{{ url('/') }}">Home</a></li>
        @if (Auth::guest())
            <li class="dropdown"><a href="{{ url('/careers') }}">Careers</a></li>

            <li class="dropdown"><a href="{{ url('/services') }}">Services</a></li>
            <li class="dropdown"><a href="{{ url('/contact') }}">Contact Us</a></li>
        @else
            <li class="dropdown">
                <a href="{{ url('/auth/careers') }}">Careers <b class="caret"></b></a>
                <ul  class="dropdown-menu">
                    <li><a href="{{ url('/auth/job-category') }}" class="dropdown-toggle">Job Category</a></li>
                    <li><a href="{{ url('/auth/position-status') }}">Position Status</a></li>
                    <li><a href="{{ url('/auth/job-type') }}">Job Type</a></li>
                    <li><a href="{{ url('/auth/city') }}">City</a></li>
                    <li><a href="{{ url('/auth/salary') }}">Salary</a></li>
                </ul>
            </li>
            <li class="dropdown"><a href="{{ url('/auth/articles') }}">Articles</a></li>
            <li class="dropdown"><a href="{{ url('/auth/register') }}">Users</a></li>
            <li class="dropdown"><a href="{{ url('/auth/logout') }}">Logout</a></li>
        @endif
        </ul>
    </div>
</div>

I also wanted to know if it would be possible to set the active link using jQuery istead of laravel / php as this would be the preferred method of doing this?

Upvotes: 1

Views: 325

Answers (1)

Tim Kruger
Tim Kruger

Reputation: 897

OK so I ended up using this package from Dwight Watson which seems to do exactly what I wanted.

You can find the package on packagist at https://packagist.org/packages/watson/active or on github at https://github.com/dwightwatson/active.

Upvotes: 0

Related Questions