Zabs
Zabs

Reputation: 14142

Create an external URL using Yii CHtml::link correctly

I am trying to create an external URL using the CHtml::link function but it always tries to create an internal link rather than an external link..

So rather than linking to google.com, it is linking to www.mysite.com/www.google.com

Any ideas (ps i know I could write this using standard HTML but i'd link to use the Yii engine as much as possible

Upvotes: 0

Views: 2723

Answers (2)

Gerardominic
Gerardominic

Reputation: 1

<?php echo CHtml::link('Text','http://www.example.com', array('class'=>''));?>

The HTTP protocol must have at the beginning of the domain.

Upvotes: 0

Ares Draguna
Ares Draguna

Reputation: 1661

This is an example on CHTML link that I used on an image... It linkes the image with google onclick.

CHtml::link( CHtml::image(Yii::app()->request->baseUrl . '/images/android.png'),('www.google.com'), array('class'=>" "));

Hope it helps!
Keep on coding!
Ares.

Upvotes: 2

Related Questions