cakephp - 无法在 cakephp 2.x 中获取带有链接的图像?

标签 cakephp cakephp-2.x

我尝试使用 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/

相关文章:

css - Cake PHP 和输入字段样式

php - CakePHP 不显示右表中的数据

cakephp - CakePHP 请求的生命周期是什么?

php - 获取 Cakephp 3 显示 bool 值的真/假

php - CakePHP 在 SELECT 输入中选择默认值

cakephp - 如何为单个列添加多个条件?

php - CakePHP 错误 : Class 'String' not found in Acl

email - 如何在cakephp中一次发送多封电子邮件

php - 在 Cakephp 中验证 Bootstrap 表单