Skip to content

Instantly share code, notes, and snippets.

@atmd83
Forked from oxyberg/menu.php
Last active December 29, 2015 17:39
Show Gist options
  • Save atmd83/7705580 to your computer and use it in GitHub Desktop.
Save atmd83/7705580 to your computer and use it in GitHub Desktop.
Function to return a class if the navigation menu is for the current url/child off in laravel 4
<?php
function menu ($url) {
if (preg_match ('#' . URL::to ($url) . '#', URL::current ())) return 'class="active"';
}
/*
* Usage
<a href="{{ URL::to ('store') }}"{{ menu ('store/*') }}>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment