Yii Framework Forum: template and CMenu - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

template and CMenu Rate Topic: ****- 1 Votes

#1 User is offline   ajaxian 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 196
  • Joined: 02-June 10

Posted 03 January 2012 - 01:02 PM

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
0

#2 User is offline   bglee 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 152
  • Joined: 21-November 10
  • Location:Oak Park, IL

Posted 03 January 2012 - 08:33 PM

Quote

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

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.
It takes 2 points to draw a straight line, but at least 3 to draw a conclusion.
0

#3 User is offline   ajaxian 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 196
  • Joined: 02-June 10

Posted 04 January 2012 - 02:13 AM

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
1

#4 User is offline   bglee 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 152
  • Joined: 21-November 10
  • Location:Oak Park, IL

Posted 04 January 2012 - 08:46 AM

Nice. I may remove that part of ArtMenu customizations.
It takes 2 points to draw a straight line, but at least 3 to draw a conclusion.
0

#5 User is offline   diegoavila 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 20-January 12

Posted 07 May 2012 - 11:59 AM

thanks for sharing this!!
0

#6 User is offline   Quincey 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 21-June 12
  • Location:Netherlands

Posted 19 July 2012 - 02:58 AM

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.


View Postajaxian, on 04 January 2012 - 02:13 AM, said:

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

0

#7 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,180
  • Joined: 05-January 12
  • Location:Morocco

Posted 19 July 2012 - 06:03 AM

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


http://www.yiiframew...c/api/1.1/CMenu
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users