我一直在努力研究如何将链接包裹在 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 来完成此任务。
最佳答案
用链接包装一个 div 听起来你想要完成这个:
<a href="product-page">
<div>
Product information
</div>
虽然这可能适用于大多数浏览器,但它是非法的(语义上不正确),因为链接不应包含 div。
我个人的选择包括向 div 添加一个 onclick 行为,它可能看起来像这样:
<div style="cursor: pointer;" onclick="window.location='http://product-page';">
Product Information goes here.
</div>
如果您仍想“用链接包装”,您可以将您的更改为 a。
关于javascript - Zen Cart 产品 div 上的可点击链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19544308/