2013-10-23 52 views
0

我一直在試圖弄清楚如何在div容器周圍包裝鏈接,以便我可以將產品列表框鏈接到產品信息頁面。我嘗試過在主頁上顯示的特色遊戲,但我無處可去。Zen Cart產品div上的可點擊鏈接

下面是代碼

$list_box_contents = array(); 
while (!$specials_index->EOF) { 
$products_price = zen_get_products_display_price($specials_index->fields['products_id']); 

$products_description = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($specials_index->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION); //To Display Product Desc 

$products_description = ltrim(substr($products_description, 0, 39) . '...'); //Trims and Limits the desc 

if (!isset($productsInCategory[$specials_index->fields['products_id']])) $productsInCategory[$specials_index->fields['products_id']] = zen_get_generated_category_path_rev($specials_index->fields['master_categories_id']); 

$specials_index->fields['products_name'] = zen_get_products_name($specials_index->fields['products_id']); 
$list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsSpecials centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"', 
'text' => (($specials_index->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : ' <div class="imagename"><div class="product_image"> 
<a href="' . zen_href_link(zen_get_info_page($specials_index->fields['products_id']), 'cPath=' . $productsInCategory[$specials_index->fields['products_id']] . '&products_id=' . (int)$specials_index->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $specials_index->fields['products_image'], $specials_index->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></div><div class="product_name">') . '<a href="' . zen_href_link(zen_get_info_page($specials_index->fields['products_id']), 'cPath=' . $productsInCategory[$specials_index->fields['products_id']] . '&products_id=' . $specials_index->fields['products_id']) . '">' . $specials_index->fields['products_name'] . '</a></div><div class="product_desc"><p class="s_desc">' . $products_description .'</p></div></div><div class="propricemain"><div class="prodprice">' . $products_price . '</div><div class="productbtn"><div class="mj-productdetailimage"><a href="' . zen_href_link(zen_get_info_page($specials_index->fields['products_id']), 'cPath=' . $productsInCategory[$specials_index->fields['products_id']] . '&products_id=' . (int)$specials_index->fields['products_id']) . '">More</a></div></div></div>'); 

我很高興能使用CSS或jQuery來做到這一點。

回答

0

結束語帶有鏈接的DIV聽起來像你想acomplish此:

<a href="product-page"> 
<div> 
    Product information 
</div> 

雖然這可能在大多數瀏覽器中運行,這是非法的(語義上不正確的),作爲鏈接不應包裝的div 。

我個人的選擇涉及添加一個onclick行爲到div至極可能是這個樣子:

<div style="cursor: pointer;" onclick="window.location='http://product-page';"> 
Product Information goes here. 
</div> 

如果你仍想「的鏈接包裹」您可以爲改變你的。