Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to get image with link in cakephp 2.x?

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

like image 966
Pank Avatar asked May 22 '13 09:05

Pank


1 Answers

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));
like image 118
Marcos Avatar answered Nov 01 '22 13:11

Marcos