Browse Source

Fixed Menu active item check.

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
07a04c526e
  1. 9
      framework/yii/bootstrap/Nav.php
  2. 9
      framework/yii/widgets/Menu.php

9
framework/yii/bootstrap/Nav.php

@ -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) {

9
framework/yii/widgets/Menu.php

@ -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) {

Loading…
Cancel
Save