Reputation: 14258
I tried to made image with link using FormHelper..in cakephp. Below are my script:
<?php
echo $this->Html->link($this->Html->image('images/view-more-arrow.png') . ' ' . __('View More'),array('controller' => 'zones', 'action' => 'index'), array('escape' => false));
?>
Output:
<a href="/project_folder/trunk/zones"><img src="/project_folder/trunk/img/images/view-more-arrow.png" alt=""> View More</a>
Expect:
<a href="/project_folder/trunk/zones"><img src="/project_folder/trunk/images/view-more-arrow.png" alt=""> View More</a>
My image directory path is project_folder/app/webroot/images. I don't know why its take img/ automatic.
Thank you in Advance..
I refereed this link: Cakephp html link with image + text, without using css
Upvotes: 6
Views: 4278
Reputation: 35
You can also try this, it works perfectly for me.
$hd = $this->Html->image('hd.jpg',array('alt'=>'harley Davidson', 'border'=>'0', 'width'=>'450', 'height'=>'250'));
echo $this->Html->link($hd,array('controller'=>'Posts', 'action'=>'add'), array('escape'=>false));
Here in $hd
, I define the path for the image and then I use this for to make link.
Upvotes: 0
Reputation: 4643
You can use the slash at the beginning of the path because is relative to the app/webroot directory:
echo $this->Html->link($this->Html->image('/images/view-more-arrow.png') . ' ' . __('View More'),array('controller' => 'zones', 'action' => 'index'), array('escape' => false));
Upvotes: 5