What’s your reason for needing the class on the anchor? If it’s just for styling or for javascript, you can select the anchor without needing to assign the “active” class.
The following rule will add the active class to the anchor element.
'items'=>array(
array('label'=>'Home', 'url'=>array('/site/index')),
array('label'=>'List', 'url'=>'',"linkOptions"=>array('href'=>CHtml::normalizeUrl(array('post/index')),'class'=>'active')),//You can set whatever the class you want.
.............................................................
To make the link really active (whenever the user is on a particular url, the corresponding menu item is also selected).
You have to overide the CMenu::isItemActive
protected function isItemActive($item,$route)
{
if(isset($item['url']) && is_array($item['url']) && !strcasecmp(trim($item['url'][0],'/'),$route))
{
unset($item['url']['#']);
if(count($item['url'])>1)
{
foreach(array_splice($item['url'],1) as $name=>$value)
{
if(!isset($_GET[$name]) || $_GET[$name]!=$value)
return false;
}
}
return true;
}
//You have to add the following thing....
if(isset($item['linkOptions']['href']))
{ $url=$item['linkOptions']['href'];
$req=Yii::app()->request->url;
if($url==$req)
return true;
}
return false;
}