Commit 07a04c52 by Qiang Xue

Fixed Menu active item check.

parent 451ff62e
......@@ -190,7 +190,14 @@ class Nav extends Widget
*/
protected function isItemActive($item)
{
if (isset($item['url']) && is_array($item['url']) && trim($item['url'][0], '/') === $this->route) {
if (isset($item['url']) && is_array($item['url']) && isset($item['url'][0])) {
$route = $item['url'][0];
if ($route[0] !== '/' && Yii::$app->controller) {
$route = Yii::$app->controller->module->getUniqueId() . '/' . $route;
}
if (ltrim($route, '/') !== $this->route) {
return false;
}
unset($item['url']['#']);
if (count($item['url']) > 1) {
foreach (array_splice($item['url'], 1) as $name => $value) {
......
......@@ -284,7 +284,14 @@ class Menu extends Widget
*/
protected function isItemActive($item)
{
if (isset($item['url']) && is_array($item['url']) && trim($item['url'][0], '/') === $this->route) {
if (isset($item['url']) && is_array($item['url']) && isset($item['url'][0])) {
$route = $item['url'][0];
if ($route[0] !== '/' && Yii::$app->controller) {
$route = Yii::$app->controller->module->getUniqueId() . '/' . $route;
}
if (ltrim($route, '/') !== $this->route) {
return false;
}
unset($item['url']['#']);
if (count($item['url']) > 1) {
foreach (array_splice($item['url'], 1) as $name => $value) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment