2016-03-01 141 views
0
<a href="../Public/singleproduct?id=<?php echo $row["Product"]["id"];?>"> 
     <div class="single-products"> 
      <div class="productinfo text-center myimg"> 
       <?php echo $this->Html->image("product/".$row["Product"]["photo"]); ?> 
       <h2>Rs.<?php echo $row["Product"]["price"];?></h2> 
       <p><?php echo $row["Product"]["name"];?></p> 
       <a href="javascript:document.ff<?php echo ($i++);?>.submit()" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a> 
       <?php echo $this->Session->flash('flash', array('element' => 'flash_notification')); ?> 
      </div> 
     </div> 
</a> 

此鏈接。CakePHP的:我怎麼能寫,因爲分頁這個網站<code><a href=""></a></code>將無法​​正常工作的其他網頁上使用分頁我需要在CakePHP的方式這個鏈接轉換CakePHP中

這是我認爲.ctp文件的所有代碼

<?php 
$i=0; 
foreach($product as $row) 
{ 
?> 
<form name="ff<?php echo $i;?>" method="post"> 
    <input type="hidden" name="product_tbls_id" value="<?php echo $row["Product"]["id"];?>"> 
    <input type="hidden" name="qty" value="1"> 
    <div class="col-sm-4"> 
     <div class="product-image-wrapper"> 
     <a href="../Public/singleproduct?id=<?php echo $row["Product"]["id"];?>"> 
      <div class="single-products"> 
      <div class="productinfo text-center myimg"> 
       <?php echo $this->Html->image("product/".$row["Product"]["photo"]); ?> 
       <h2>Rs.<?php echo $row["Product"]["price"];?></h2> 
       <p><?php echo $row["Product"]["name"];?></p> 
       <a href="javascript:document.ff<?php echo ($i++);?>.submit()" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a> 
       <?php echo $this->Session->flash('flash', array('element' => 'flash_notification')); ?> 
      </div> 
      </div> 
     </a> 
     </div> 
    </div> 
</form> 
<?php 
} 
?> 

回答

0

我想這和它的工作me.Posting回答,只是因爲可能是它可以幫助有人。

<?php 
    echo $this->Html->link('<div class="single-products">'.'<div class="productinfo text-center myimg">'.$this->Html->image("product/".$row["Product"]["photo"]).'<h2>'.$row["Product"]["price"].'</h2>'.'<p>'.$row["Product"]["name"]."</p><a href='javascript:document.ff".($i++).".submit()' class='btn btn-default add-to-cart'><i class='fa fa-shopping-cart'></i>Add to cart</a>".$this->Session->flash('flash', array('element' => 'flash_notification')).'</div>'.'</div>', 
                       array 
                       (
                        'controller'=>'Public', 
                        'action'=>'singleproduct?id='.$row["Product"]["id"], 
                       ), 
                       array 
                       (
                        'escape'=>false 
                       ) 
                      ); 
?> 
0

你的問題是有點混亂。 還在考慮爲「公開」爲「控制器」和「singleproduct」爲「行動」,你可以寫這樣:

<?php echo $this->Html->link('link text here', array(
'controller' => 'Public', 
'action' => 'singleproduct', 
'?' => array('id' => $row["Product"]["id"])) 
); ?> 
+0

我知道這個,但有div和div和其他鏈接,所以我不知道該怎麼做。請提及 – Vky

+0

,並提及您嘗試過的內容。所以我們可以明白。 –

+0

我想這樣[鏈接](http://stackoverflow.com/questions/13250788/cakephp-linking-the-whole-div)但那不是我的,所以我找不到我的解決方案。但嘗試 – Vky

相關問題