Created
July 2, 2012 00:49
-
-
Save machuga/3030270 to your computer and use it in GitHub Desktop.
Simplistic Laravel Breadcrumb macro
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
<?php | |
HTML::macro('breadcrumbs', function() { | |
$links = ''; | |
$current = URI::current(); | |
if ($current != '/') | |
{ | |
return array_reduce(explode('/', URI::current()), function($t,$c) use (&$current, &$links) { | |
$links = $links ? $links.'/'.$c : $c; | |
$active = 'active'; | |
$divider = ''; | |
$content = Str::title(str_replace(['_', '-'], ' ', $c)); | |
if ($current != $links) | |
{ | |
$active = ''; | |
$divider = '<span class="divider">/</span>'; | |
$content = HTML::link($links, $content); | |
} | |
$html = '<li class="'.$active.'">'.$content.'</li>'.$divider; | |
return $t .= $html; | |
}); | |
} | |
else | |
{ | |
return '<li class="active">Home</li>'; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Removed bad implementation.