G
G
Grag2014-02-12 17:52:37
Yii
Grag, 2014-02-12 17:52:37

Does CMenu (Yii) support images?

$this->widget('zii.widgets.CMenu', array(
    'items'=>array(
        // Important: you need to specify url as 'controller/action',
        // not just as 'controller' even if default acion is used.
        array('label'=>'Home', 'url'=>array('site/index')),
        // 'Products' menu item will be selected no matter which tag parameter value is since it's not specified.
        array('label'=>'Products', 'url'=>array('product/index'), 'items'=>array(
            array('label'=>'New Arrivals', 'url'=>array('product/new', 'tag'=>'new')),
            array('label'=>'Most Popular', 'url'=>array('product/index', 'tag'=>'popular')),
        )),
        array('label'=>'Login', 'url'=>array('site/login'), 'visible'=>Yii::app()->user->isGuest),
    ),
));

Does this Yii feature involve inserting images into 'label'?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Kasymov, 2014-02-12
@Grag

Yes.
to do this, turn off label coding

$this->widget('zii.widgets.CMenu', array(
    'encodeLabel'=>false,
...

and then you can do
and for obviously dangerous data that can come in a variable, use forced encoding of dangerous characters:array('label'=>CHtml::encode($you_var))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question