Tuesday, November 6, 2012

HtmlHelper->image. Making using HtmlHelper image function to create a link to a external sites url

My problem is quite simple: How do I  create <img>-tags with an external url using cakephp's htmlhelper ? I have a site that hosts all static content, such as images and javascripts and I need to use it's address on my sites.

CASE
Lets assume my cake is running at http://www.mysite.com/caek/

My view code is like this (i'll seperate the variables for easier reading)
<code>
<?php
    $address="http://static.site.com/image.png"; //this variable will come from controller.
    echo $this->Html->image($address, array('alt' => 'alt text'));
?>
</code>

This will output something like this: <img src="caek/http://static.site.com/image.png" alt="alt text" /> .

While what I want is: <img src="http://static.site.com/image.png" alt="alt text" /> .


I could do this by echoing the right tags and such with the variables, but I'm in a state of mind that I want to solve the problem, instead of going around it.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: