Moe Moe - 2 years ago 181
PHP Question

Laravel 4.1 Request::is for active menu not working

I'm trying to make a menu active depending on route in laravel 4.1, my attempt:

{{{ (Request::is('/core') ? 'class="active"' : '') }}}><a href="{{{ URL::to('/core') }}}">Control Panel</a>

My route:

Route::get('/core', 'CoreController@Showindex');

This is not throwing any errors just simply ignored. any help is appreciated.

Moe Moe
Answer Source

changed to:

   {{{ (Request::is('/core') ? 'class=active' : '') }}}><a href="{{{ URL::to('/core')  }}}">Control Panel</a>

from 'class="active"' to 'class=active'

This working fine for <li> tag but not <a> tag, needs to be used like so:

<a href="{{{ URL::to('core') }}}" class="list-group-item {{{ (Request::is('core') ? 'active' : '') }}}">Overview</a>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download