私のページには、データベースに結果がある場合にのみ表示したい色見本 (およびタイル AVAIALBLE COLOURS) の領域があります。
ここに私のコードがあります:
private function getWTVariationHighlights($productId, $variationId)
{
$output_str = "";
$output_str .="<div class=\"mainProductSwatchesTitle\"><b>AVAILABLE COLOURS</b>\n";
$output_str .= "<div class=\"mainProductSwatches\">\n";
$sql = "select voptionid, vovalue from [|PREFIX|]product_variation_options where vovariationid=$variationId and (voname='Colour' or voname='Color')";
$result = $this->db->Query($sql);
while ($row = $this->db->fetch($result)) {
$sql = "select * from [|PREFIX|]variation_option_highlight where variation_option_id=" . $row['voptionid'] . " and product_id=" . $productId;
$result2 = $this->db->Query($sql);
if($row2 = $this->db->fetch($result2)){
if($row2['thumb_location']){
$output_str .= "<a href=\"#\" onmouseover=\"changeMain('" . $row2['location'] . "')\"><img src=\""
. $GLOBALS['ShopPath'] . "/product_images/hfh_highlight_images/" . $row2['thumb_location'] . "\" /></a>\n";
}
}
}
$output_str .= "</div>\n";
$output_str .= "<script type=\"text/javascript\">\n";
$output_str .= "function changeMain(src)\n";
$output_str .= "{\n";
$output_str .= "document.getElementById('phthumb').src = '" . $GLOBALS['ShopPath'] . "/product_images/hfh_highlight_images/' + src;\n";
$output_str .= "}\n";
$output_str .= "</script>\n";
return $output_str;
}