Skip to content

Instantly share code, notes, and snippets.

@Ryadnov
Created September 11, 2012 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ryadnov/3700652 to your computer and use it in GitHub Desktop.
Save Ryadnov/3700652 to your computer and use it in GitHub Desktop.
cmenu - class active в ссылку (http://yiiframework.ru/forum/viewtopic.php?f=3&t=8403)
<?php
Yii::import('zii.widgets.CMenu');
class Menu extends CMenu
{
protected function normalizeItems($items, $route, &$active)
{
$items = parent::normalizeItems($items, $route, $active);
foreach($items as $i => $item)
{
if ($item['active'])
{
if (!isset($item['linkOptions']))
$items[$i]['linkOptions'] = array('class' => $this->activeCssClass);
else
$items[$i]['linkOptions']['class'] = (isset($item['linkOptions']['class']) ? $item['linkOptions']['class'] . ' ' : ''). $this->activeCssClass;
$items[$i]['active'] = false;
}
}
return $items;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment