Quantcast
Channel: Live News for Yii Framework
Viewing all articles
Browse latest Browse all 3378

[Wiki] Yii 1.1: How To add id or class to CMenu items ?

$
0
0

CMenu comes with a lot of great customization options built in. One of the most used is the class 'active' being added to menu item. But, what if you want to add your own class or id to a menu item ?

It's very easy, you just need to use the 'itemOptions'.

If you want a menu like :

<ul id="myMenu">
            <li  id="first"><a href="#"><span>First</span></a></li>
            <li id="second"><a href="#"><span>Second</span></a></li>
</ul>

Just do :

<?php $this->widget('application.components.MyMenu', array(
    'id' => 'myMenu',
    'items' => array(
       array('label' => 'First', 'url' => array('#'), 'itemOptions'=>array('id' => 'first'), ),
       array('label' => 'First', 'url' => array('#'), 'itemOptions'=>array('id' => 'second'), ),
    ),
));
?>

That's all folks !


Viewing all articles
Browse latest Browse all 3378

Latest Images

Trending Articles



Latest Images