2014-11-14 26 views
0

我想在HTML的代码如何在cakephp的单个链接中显示两个或三个图像?

<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> 

我怎么能做到这一点,请回复这个?

+0

你的问题是一团糟。请考虑重写。 – Rvervuurt 2014-11-14 13:28:25

+0

请在创建帖子时使用代码按钮以良好缩进并突出显示代码。你目前的产出是多少? (把它放在'代码') – RichardBernards 2014-11-14 13:29:22

回答

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下,则它应该具有完整路径,或者如果它存在,则可以忽略开始/

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

+0

嗨,朋友感谢您的回复,但我仍然没有得到期望的结果,我现在得到( Pant Suit) – 2014-11-17 13:17:02

+0

现在我成功了。 – 2015-02-09 13:56:10

相关问题