2014-11-14 27 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

相關問題