From 4a2b01cd9af74b99408fef215509f9db224211f6 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 09:16:17 +0200 Subject: [PATCH] Menu fixes [skip ci] --- app/Support/Twig/General.php | 16 +++++++++++----- resources/twig/partials/menu.twig | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index cf9c8cef88..5b2088beab 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -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'; + } } } diff --git a/resources/twig/partials/menu.twig b/resources/twig/partials/menu.twig index 91eec49241..da0704dfd3 100644 --- a/resources/twig/partials/menu.twig +++ b/resources/twig/partials/menu.twig @@ -90,7 +90,7 @@
  • - Dashboard + Dashboard
  • Accounts