template and CMenu

Hi all,

I search for creating such menu:


<li>

<a href='...'><strong>My Label</strong><span>My explain</span></a>

</li>

But I’m unable to do this with CMenu

I try many configuration … but still doesn’t work (using template, and or linkLabelWrapper …)




<?php $this->widget('zii.widgets.CMenu',array(

                            'items'=>array(


                                array('label'=>'Home',                                     

                                    'template'=>'<strong>{menu}</strong><span>Sweet Home</span>',

                                    'url'=>array('/')

                                        ),


                                    )


                            )

                        )); ?>



I try this but it gives


<li ><strong><a href="...">Home</a></strong><span>Sweet Home</span></li>



Is there a way to do it with Cmenu without extanding CMenu class ?

Thanks

I don’t believe there is. I had the same issue some time ago while trying to get Artisteer generated themes to work in Yii. I ended up creating a drop in replacement for CMenu (after extending it was broken by an upgrade). Go to Yii Themes Site - Bright Ideas Theme and download the theme (or any other Artisteer theme). ArtMenu.php is included in the download. ArtMenu includes a ‘prelinklabel’ and a ‘postlinklabel’ that will do what you want.

Thanks

I found the solution without breaking or extending:

placing


'encodeLabel'=>false,

at first level of options description in CMenu. Not in items description. That was my fault at start and then nothing worked.

then you write anything you want in items label.


'label'=>'Home<span>Sweet Home</span>', OR 'label'=>'<strong>Home</strong><span>Sweet Home</span>',

That was as simple as this.

regards

Nice. I may remove that part of ArtMenu customizations.

thanks for sharing this!!

Hi Ajaxian,

I just design my first template for yii in Artisteer. I’m to stuck on the Menu issue. Where precisely did you put the the code?


'encodeLabel'=>false,

I just start learning Yii and PHP.

All the help is welcome.

thanks.


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

    'encodeLabel'=>false,

    'items'=>array(

        …

    )

));

http://www.yiiframework.com/doc/api/1.1/CMenu