YII CMenu配置

阅读更多

Adding id and class names to CMenu

We use the id and htmlOptions to accomplish this. Watch.

//in your view
$this->widget('zii.widgets.CMenu', array(
	'id'=>'myMenu',
	'items'=>$this->myMenu,
	'htmlOptions'=>array('class'=>'span-24 last'),
));

this will make Yii render

    class="span-24 last" id="myMenu"> ...
 

Adding class names to CMenu items and CMenu item links

We use itemOptions and linkOptions for this. Example.

//in your controller
$this->myMenu = array(
'id'=>'myMenu',
'items'=>array(
	array(
		'label'=>'Home',
		'url'=>array('site/index'),
		'itemOptions'=>array('class'=>'visited'),
		'linkOptions'=>array('class'=>'bar'),
	),
	array('label'=>'Sign Out', 'url'=>array('site/signout')),
),
);

This will let Yii render
...

你可能感兴趣的:(yii)