如何在cakephp的单个链接中使用两个或三个图像?

时间:2014-11-14 13:20:44

标签: php jquery html css cakephp

我想在html

中使用此代码
<a href="images/p191-large.jpg" class="cloud-zoom-gallery" rel="useZoom: 'zoom11',  smallImage: 'images/p191.jpg' " title="Women's Crepe Printed Black"> 
    <img class="zoom-tiny-image" itemprop="image" src="images/p191.jpg" width="80" height="97" alt=""/>
</a>

我已经在cakephp中编写了这段代码以获得上述结果

<?php
echo $this->Html->link(
    $this->Html->image("p191.jpg", array(
        "alt" => "Pant Suit",
        "width" => "80",
        "height" => "97",
        'class' => 'zoom-tiny-image'
    )),
    array(
        'controller' => 'admins',
        'action' => '$this->Html->image(p191.jpg)'
    ),
    array(
        'class' => 'cloud-zoom-gallery',
        'title' => 'Women\'s Crepe Printed Black',
        'escape' => false,
        'rel' => "useZoom: 'zoom11', smallImage: 'images/p191.jpg' "
    )
);
?>

但是将其作为输出

<a href="/stylishtailor1/admins/ ;image(p191.jpg)" class="cloud-zoom-gallery" title="Women's Crepe Printed Black" rel="useZoom: 'zoom11', smallImage: 'images/p191.jpg' ">
    <img src="/stylishtailor1/images/p191.jpg" alt="Pant Suit" width="80" height="97" class="zoom-tiny-image" />
</a>

我怎么能这样做,请回复这个???

1 个答案:

答案 0 :(得分:0)

这是您所需的最接近的代码:

<?php
    echo $this->Html->link(
            $this->Html->image('/images/p191-large.jpg', array('alt' => 'Pant Suit', 'width' => '80', 'height' => '97', 'class' => 'zoom-tiny-image')),
            'images/p191-large.jpg',
            array('class' => 'cloud-zoom-gallery', 'title' => 'Women\'s Crepe Printed Black', 'escape' => false, 'rel' => "useZoom: 'zoom11', smallImage: 'images/p191.jpg' ")
    );
?>

为了确保它正常工作,你必须检查两件事。图像路径(image()函数的第一个参数)如果它不在webroot / img下面,或者如果它在那里,则应该具有完整路径,可以省略开始/。 / p>

要检查的第二件事是您的网址位置(link()函数中的第二个参数)。您也可以将其作为字符串或路由数组传递。在你的例子中,你传递了非常奇怪的数组。