我尝试使用 CakePHP 中的 FormHelper.. 制作带有链接的图像。以下是我的脚本:
<?php
echo $this->Html->link($this->Html->image('images/view-more-arrow.png') . ' ' . __('View More'),array('controller' => 'zones', 'action' => 'index'), array('escape' => false));
?>
输出:
<a href="/project_folder/trunk/zones"><img src="/project_folder/trunk/img/images/view-more-arrow.png" alt=""> View More</a>
预期:
<a href="/project_folder/trunk/zones"><img src="/project_folder/trunk/images/view-more-arrow.png" alt=""> View More</a>
我的图像目录路径是project_folder/app/webroot/images。我不知道为什么它采用 img/automatic。
提前谢谢您..
我引用了这个链接: Cakephp html link with image + text, without using css
最佳答案
您可以在路径开头使用斜杠,因为它是相对于 app/webroot 目录的:
echo $this->Html->link($this->Html->image('/images/view-more-arrow.png') . ' ' . __('View More'),array('controller' => 'zones', 'action' => 'index'), array('escape' => false));
关于cakephp - 无法在 cakephp 2.x 中获取带有链接的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16688167/