Created
December 20, 2013 13:07
-
-
Save lighta971/8054541 to your computer and use it in GitHub Desktop.
Laravel Menu active state helper Add to composer.json:
"autoload": { "files": ["app/helpers.php"]
} Then run "composer dump" #http://paste.laravel.com/1acS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// helper | |
function set_active($path, $active = 'active') { | |
return call_user_func_array('Request::is', (array)$path) ? $active : ''; | |
} | |
// usage in view | |
<li class="{{ set_active(['admin/institutes*','admin/courses*']) }}"> | |
or | |
<li class="{{ set_active('admin/dashboard') }}"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment