phphtmlyiiyii-chtml

Yii - creating absolute URLs with CHTML::link()


I've used the CHTML::link() to create links however it doesn't seem to work for absolute URLs

My Code:

<?php echo CHtml::link(CHtml::image(Yii::app()->baseUrl.'/images/image.png'), array('/http://www.newsite.com/about/'));?>

The link returns the site baseUrl so it appears like this

http://currentsitecom/http://www.newsite.com/about/

Can anyone suggest why this doesn't work?


Solution

  • The link shouldn't have / before http://

    <?php echo CHtml::link(
        CHtml::image(Yii::app()->baseUrl.'/images/image.png'),
        array('http://www.newsite.com/about/')
    );?>