From d81933f0021e6ba5e3100fa4d392c9d7eebccb26 Mon Sep 17 00:00:00 2001 From: Danang Probo Sayekti Date: Sat, 14 Nov 2015 21:59:53 +0700 Subject: [PATCH] Improve custom menu Add active menu link to custom menu --- system/includes/functions.php | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/system/includes/functions.php b/system/includes/functions.php index bc5bc63..24565e3 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -1621,7 +1621,7 @@ EOF; function menu($custom = null) { $menu = config('blog.menu'); - $req = $_SERVER['REQUEST_URI']; + $req = strtok($_SERVER["REQUEST_URI"],'?'); if (!empty($menu)) { @@ -1649,24 +1649,20 @@ function menu($custom = null) if (isset($anc[0]) && isset($anc[1])) { if (stripos(rtrim($anc[1], '/') . '/', site_url()) !== false) { - $id = substr($link, strrpos($link, '/') + 1); - $file = 'content/static/' . $id . '.md'; - if (file_exists($file)) { - if (stripos($req, $id) !== false) { - echo '
  • ' . $anc[0] . '
  • '; + if (rtrim($anc[1], '/') . '/' == site_url()) { + if ($req == site_path() . '/' || stripos($req, site_path() . '/?page') !== false) { + echo '
  • ' . config('breadcrumb.home') . '
  • '; } else { - echo '
  • ' . $anc[0] . '
  • '; + echo '
  • ' . config('breadcrumb.home') . '
  • '; } - } else { - if (rtrim($anc[1], '/') . '/' == site_url()) { - if ($req == site_path() . '/') { - echo '
  • ' . config('breadcrumb.home') . '
  • '; - } else { - echo '
  • ' . config('breadcrumb.home') . '
  • '; - } - } else { + } elseif (stripos($anc[1], $req) !== false) { + if ($req == site_path() . '/' || stripos($req, site_path() . '/?page') !== false) { echo '
  • ' . $anc[0] . '
  • '; + } else { + echo '
  • ' . $anc[0] . '
  • '; } + } else { + echo '
  • ' . $anc[0] . '
  • '; } } else { echo '
  • ' . $anc[0] . '
  • ';