Yii Framework Forum: Image Inside Anchor Tag - Yii Framework Forum

Jump to content

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

Image Inside Anchor Tag Image inside anchor tag in Cmenu Rate Topic: -----

#1 User is offline   Neeraj Kumar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 09-June 12

Posted 07 December 2012 - 03:12 PM

Hello,

I need help

I want to and output like this
<a href="abc.php"><img src="abc.jpg" /></a>

I tried like this

$login = Yii::app()->request->baseUrl."/css/images/site/login.png";
$this->widget('zii.widgets.CMenu', array(
'items' => array(
array('label' => "<img src='$login' alt=''>",
'itemOptions' => array('class' => 'hdr_link'),
'url' => array('/user/login'), 'visible' => Yii::app()->user->isGuest),
),
));

but it dont gives me correct output

Please help me out.

Thanks in Advance.
0

#2 User is online   alirz23 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 967
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 07 December 2012 - 03:33 PM

this should do it

$login = Yii::app()->request->baseUrl."/css/images/site/login.png";
$this->widget('zii.widgets.CMenu', array(
'items' => array(
array('label' => CHtml::image($login),
'itemOptions' => array('class' => 'hdr_link'),
'url' => array('/user/login'), 'visible' => Yii::app()->user->isGuest),
),
));

0

#3 User is offline   yugene 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 513
  • Joined: 08-August 09

Posted 08 December 2012 - 04:20 AM

You'll also need to set encodeLabel to false


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