Menu fixes [skip ci]

This commit is contained in:
James Cole 2015-05-02 09:16:17 +02:00
parent 803827e05c
commit 4a2b01cd9a
2 changed files with 12 additions and 6 deletions

View File

@ -92,18 +92,24 @@ class General extends Twig_Extension
$functions[] = new Twig_SimpleFunction(
'activeRoute', function ($context) {
$args = func_get_args();
$route = $args[1];
$what = isset($args[2]) ? $args[2] : false;
$args = func_get_args();
$route = $args[1];
$what = isset($args[2]) ? $args[2] : false;
$strict = isset($args[3]) ? $args[3] : false;
$activeWhat = isset($context['what']) ? $context['what'] : false;
// activeRoute
if (!($what === false)) {
if ($what == $activeWhat && Route::getCurrentRoute()->getName() == $route) {
return 'active because-active-what';
}
} else {
if (Route::getCurrentRoute()->getName() == $route) {
return 'active because-route-matches';
if (!$strict && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
return 'active because-route-matches-non-strict';
} else {
if ($strict && Route::getCurrentRoute()->getName() == $route) {
return 'active because-route-matches-strict';
}
}
}

View File

@ -90,7 +90,7 @@
<!-- /input-group -->
</li>
<li>
<a class="{{ activeRoute('index') }}" href="{{ route('index') }}"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a>
<a class="{{ activeRoute('index',null,true) }}" href="{{ route('index') }}"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a>
</li>
<li class="{{ activeRoute('accounts.index') }}">
<a href="#"><i class="fa fa-credit-card fa-fw"></i> Accounts <span class="fa arrow"></span></a>