SiteMenu.php
805 Bytes
<?php
Yii::import('zii.widgets.CMenu');
class SiteMenu extends CMenu
{
public function init()
{
$this->htmlOptions['id'] = $this->getId();
$route = $this->getController()->getRoute();
$items = array();
$mainMenu = SiteMenuHelper::getItems();
foreach ($this->items as $k)
if(isset($mainMenu[$k])){
$item = $mainMenu[$k];
$items[] = array(
'url' => $item['url'],
'label' => $item['label'],
'active' => $this->evaluateExpression($item['active'],array('controller'=>$this->getController())),
);
}
$this->items = $items;
$hasActiveChild = false;
$this->items = $this->normalizeItems($this->items, $route, $hasActiveChild);
}
}