【问题标题】:link and image helper error链接和图像助手错误
【发布时间】:2011-12-23 21:12:12
【问题描述】:

我尝试使用灯箱,我按照link 中的所有步骤操作,但代码中存在问题

<a href="images/image-1.jpg" rel="lightbox">
<img src="images/thumb-1.jpg" width="100" height="40" alt="" />
</a>

我把 images 文件夹放在 webroot 中

C:\wamp\www\tet\app\webroot\img\images

我用上面的代码代替

$thumb = $this->Html->image('images/thumb-1.jpg');
$full = $this->Html->image('/images/image-1.jpg', array('rel' => 'lightbox'));
echo $this->Html->link($thumb,$full, array('escape' => false));

但我仍然看到这个错误

Missing Method in ImagesController

Error: The action <img src=" is not defined in controller ImagesController

Error: Create ImagesController::<img src="() in file: app\controllers\images_controller.php.

<?php
class ImagesController extends AppController {

    var $name = 'Images';


    function <img src="() {

    }

}
?>

请帮忙

【问题讨论】:

    标签: cakephp cakephp-1.3


    【解决方案1】:

    因为你做错了。应该是这样的

       $this->Html->image('images/thumb-1.jpg', array('url' => 'images/image-1.jpg'));
    

    【讨论】:

    • 不,您的代码不正确,因为我是这样的图像文件夹 C:\wamp\www\tet\app\webroot\img\images
    • 在这种情况下删除前导斜杠。我已经更新了代码。
    • 不,它不起作用..当我单击图像时,像这样localhost/tet/images/images/image-1.jpg...and 的链接仍然会看到此错误。ImagesController 中缺少方法错误:动作图像未在控制器中定义 ImagesController 错误:在文件 app\controllers\images_controller.php 中创建 ImagesController::images()。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-05
    • 1970-01-01
    • 1970-01-01
    • 2016-08-02
    • 2023-03-05
    相关资源
    最近更新 更多