From 3a91bc30389c1e4927f3a2c3aaa4e2da37f26a29 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 9 May 2024 00:03:56 +0900 Subject: [PATCH] Fix incorrect admin menu opening in Dashboard #2345 --- modules/admin/controllers/Base.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/modules/admin/controllers/Base.php b/modules/admin/controllers/Base.php index bef63a2cb..fecd6179d 100644 --- a/modules/admin/controllers/Base.php +++ b/modules/admin/controllers/Base.php @@ -112,14 +112,21 @@ class Base extends \ModuleObject break; } } - if (!$subMenuTitle && count($moduleMenus)) + if (!$subMenuTitle && $currentAct && count($moduleMenus)) { $subMenuTitle = array_first($moduleMenus)->title; } if (!$subMenuTitle) { - $moduleInfo = \ModuleModel::getModuleInfoXml($module); - $subMenuTitle = $moduleInfo->title ?? 'Dashboard'; + if ($currentAct) + { + $moduleInfo = \ModuleModel::getModuleInfoXml($module); + $subMenuTitle = $moduleInfo->title ?? 'Dashboard'; + } + else + { + $subMenuTitle = 'Dashboard'; + } } // get current menu's srl(=parentSrl) @@ -135,12 +142,14 @@ class Base extends \ModuleObject $firstChild = current($parentMenu['list']); $menu->list[$parentKey]['href'] = $firstChild['href']; } - - foreach ($parentMenu['list'] as $childMenu) + if ($currentAct) { - if ($subMenuTitle == $childMenu['text'] && $parentSrl == 0) + foreach ($parentMenu['list'] as $childMenu) { - $parentSrl = $childMenu['parent_srl']; + if (preg_match('/\b' . preg_quote($currentAct, '/') . '$/', $childMenu['href'])) + { + $parentSrl = $childMenu['parent_srl']; + } } } }