在 cakephp 1.3 中编写此帮助程序代码的正确方法是什么

发布于 2024-12-22 14:30:56 字数 865 浏览 1 评论 0原文

我使用灯箱,但显示灯箱的代码有问题 而不是

<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>

我使用此代码进行查看

   $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));

,但我看到此错误

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="() {

    }

}
?>

Notice: If you want to customize this error message, create app\views\errors\missing_action.ctp

i use light box but something wrong with this code to show light-box
instead of

<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>

i use this code for view

   $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));

but i see this error

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="() {

    }

}
?>

Notice: If you want to customize this error message, create app\views\errors\missing_action.ctp

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你是暖光i 2024-12-29 14:30:56

翻译说明

Lightbox 2 使用原型框架和 Scriptaculous 效果库。您需要将这三个 Javascript 文件包含在您的
标头(按此顺序)。

;
;
<脚本类型=“text/javascript”src=“js/lightbox.js”>

对于 Cake,这意味着将这些行放入 default.ctp 布局中,并将 Javascript 文件放入 webroot/js 文件夹中。

包含 Lightbox CSS 文件(或附加带有 Lightbox 样式的活动样式表)。


再次将其放入布局中,并将 css 文件放入 webroot/css 中。

检查 CSS 并确保引用的 prev.gifnext.gif
文件位于正确的位置。另外,请确保 loading.gif
close.gif 文件在 lightbox.js 文件顶部附近引用
位于正确的位置。

确保图像位于 webroot/img 中的正确位置,根据需要调整路径。

向任何链接标记添加 rel="lightbox" 属性以激活
灯箱。例如:

图像 #1

您可以通过向链接帮助器添加属性来执行此操作:

$this->Html->link('image #1', '/img/images-1.jpg', array('rel' => 'lightbox'));

Translating the instructions:

Lightbox 2 uses the Prototype Framework and Scriptaculous Effects Library. You will need to include these three Javascript files in your
header (in this order).

<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>

For Cake that means to put these lines into your default.ctp layout and the Javascript files into the webroot/js folder.

Include the Lightbox CSS file (or append your active stylesheet with the Lightbox styles).

<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />

Again, put this in the layout and the css file into webroot/css.

Check the CSS and make sure the referenced prev.gif and next.gif
files are in the right location. Also, make sure the loading.gif and
close.gif files as referenced near the top of the lightbox.js file
are in the right location.

Make sure the images are in the right location in webroot/img, adjust paths as necessary.

Add a rel="lightbox" attribute to any link tag to activate the
lightbox. For example:

<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>

In you do this by adding attributes to the link helper:

$this->Html->link('image #1', '/img/images-1.jpg', array('rel' => 'lightbox'));
醉梦枕江山 2024-12-29 14:30:56

由于您没有列出您尝试过的任何代码,所以我假设您还没有开始集成。检查此链接,它有您需要的内容:
使用 CakePHP 的灯箱

Since you have not listed any code you tried, so i assume you've not started integration. Check this link, it have what you need:
Lightbox using CakePHP

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文