Yii Framework Forum: How to pass array data in a url? - Yii Framework Forum

Jump to content

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

How to pass array data in a url? Rate Topic: -----

#1 User is offline   bambinou 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 06-August 13

Posted 15 December 2014 - 02:08 PM

Hi All,


I would like to pass my array data into a url:
this is the array data:
array('dealPayments/buy', 'dealid' => $model->id),


Which I would like to pass into a <a> so when someone clicks and image it gets send to the url set by the array data.

I tried this:
echo CHtml::link(

but it is unfortunately echoing the <a> tag inside my href, I only need the url with the arrway data at the end , how to do this please?


Thank you,

Ben
0

#2 User is offline   moginn 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 130
  • Joined: 07-April 12
  • Location:Spain

Posted 19 December 2014 - 09:49 PM

You can use createUrl or createAbsoluteUrl

Yii::app()->createAbsoluteUrl('controller/action', array('lang' => 'en'));


You can put a link on an image like this:

echo CHtml::link(CHtml::image(Yii::app()->baseUrl . '/images/myimage.gif'), array('controller/action'));

0

#3 User is offline   bambinou 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 06-August 13

Posted 20 December 2014 - 09:05 AM

Thank you Moginn,

Is it the same for both Yii 1 and Yii 2 please?

Thank you,

Ben
0

#4 User is offline   moginn 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 130
  • Joined: 07-April 12
  • Location:Spain

Posted 20 December 2014 - 09:26 AM

View Postbambinou, on 20 December 2014 - 09:05 AM, said:

Thank you Moginn,

Is it the same for both Yii 1 and Yii 2 please?

Thank you,

Ben


In Yii 2 to create a link you should use Html::a

http://www.yiiframew...#a%28%29-detail

to create an image you should use Html::img

http://www.yiiframew...mg%28%29-detail

to create url you should use Url

http://www.bsourceco...2-url-creation/
0

#5 User is offline   bambinou 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 06-August 13

Posted 21 December 2014 - 04:56 PM

Thank you so much!
The last link you gave me is a bit of a gold mine (: thats exactly what I was looking for!


Thanks,

Ben
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