Yii Framework Forum: CHtml many items in link - Yii Framework Forum

Jump to content

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

CHtml many items in link Rate Topic: -----

#1 User is offline   Speeedfire 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 182
  • Joined: 02-March 12

Posted 10 April 2012 - 03:17 PM

How to create many items with CHtml::link?
If i use array in the first tag, the link is text array.

<a href="#">
<img src=""/><img src="">
</a>


example
0

#2 User is offline   rookie84 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 114
  • Joined: 16-November 11

Posted 10 April 2012 - 11:05 PM

You can do it like this, for example:

$image1 = CHtml::image(Yii::app()->baseUrl.'/image1.png');
$image2 = CHtml::image(Yii::app()->baseUrl.'/image2.png');

echo CHtml::link($image1.$image2, array('controller/action'));
0

#3 User is offline   Speeedfire 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 182
  • Joined: 02-March 12

Posted 11 April 2012 - 07:47 AM

View Postrookie84, on 10 April 2012 - 11:05 PM, said:

You can do it like this, for example:

$image1 = CHtml::image(Yii::app()->baseUrl.'/image1.png');
$image2 = CHtml::image(Yii::app()->baseUrl.'/image2.png');

echo CHtml::link($image1.$image2, array('controller/action'));


It's doesn't work. :(
0

#4 User is offline   rookie84 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 114
  • Joined: 16-November 11

Posted 12 April 2012 - 11:40 AM

I just tested and it does work! Whats wrong with it? You getting an error or something?
0

#5 User is offline   Speeedfire 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 182
  • Joined: 02-March 12

Posted 12 April 2012 - 12:09 PM

View Postrookie84, on 12 April 2012 - 11:40 AM, said:

I just tested and it does work! Whats wrong with it? You getting an error or something?


I have many attribute in link array, and the link is wrong.

$image1 = CHtml::image(Yii::app()->baseUrl.'/image1.png');
            $image2 = CHtml::image(Yii::app()->baseUrl.'/image2.png');

            echo CHtml::link($image1.$image2, array("class"=>"example",Yii::app()->baseUrl.'/example'));

0

#6 User is offline   xent 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 97
  • Joined: 14-November 10

Posted 12 April 2012 - 07:05 PM

check doc here http://www.yiiframew...tml#link-detail

the CHtml::link format must match pattern
link(string $text, mixed $url='#', array $htmlOptions=array ( ))


change your code to
echo CHtml::link($image1.$image2,Yii::app()->baseUrl.'/example' , array("class"=>"example"));

xent

My first app: School Information System
Find error? Post here
My Blog
1

#7 User is offline   Speeedfire 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 182
  • Joined: 02-March 12

Posted 13 April 2012 - 03:24 PM

View Postxent, on 12 April 2012 - 07:05 PM, said:

check doc here http://www.yiiframew...tml#link-detail

the CHtml::link format must match pattern
link(string $text, mixed $url='#', array $htmlOptions=array ( ))


change your code to
echo CHtml::link($image1.$image2,Yii::app()->baseUrl.'/example' , array("class"=>"example"));



Ohh, thx. :)
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