给Zen-cart产品分类列表页产品评论星星(代码)

1,给产品列表页面的产品添加评论小星星
打开文件includes\modules\你的模板\product_listing.php
[php]
$lc_text .= ” . (zen_get_show_product_switch($listing->fields[‘products_id’], ‘ALWAYS_FREE_SHIPPING_IMAGE_SWITCH’) ? (zen_get_product_is_always_free_shipping($listing->fields[‘products_id’]) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . ‘<br />’ : ”) : ”)
[/php]
#前面一行插入
[php]
//显示评论星星start
$count_stars_query = "select count(reviews_rating) as num, avg(reviews_rating) as aver from " . TABLE_REVIEWS . " where products_id = ‘" . (int)$listing->fields[‘products_id’] . "’";
$count_stars = $db->Execute($count_stars_query);
$starnum = round($count_stars->fields[‘aver’]);
$star = array("stars_1.gif","stars_2.gif","stars_3.gif","stars_4.gif","stars_5.gif");
if($count_stars->fields[‘num’]>=1){
$reviews_display ='<div class="listreviews"><img src="includes/templates/你的模板/images/’. $star[$starnum-1] .’" />(‘.$count_stars->fields[‘num’].’)</div>’;
}else{
$reviews_display ='<div class="listreviews"><img src="includes/templates/你的模板/images/stars_0.gif" />(0)</div>’;
}
//显示评论星星end
[/php]
#然后在最开始的那段代码后天面添加$reviews_display就可以了:例如
[php]
$lc_text .= ” . (zen_get_show_product_switch($listing->fields[‘products_id’], ‘ALWAYS_FREE_SHIPPING_IMAGE_SWITCH’) ? (zen_get_product_is_always_free_shipping($listing->fields[‘products_id’]) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . ‘<br />’ : ”) : ”) .'<br />’.$reviews_display;
[/php]
这样,如果在前台页面显示位置不对,自己可以将$reviews_display位置稍作调试。(确认你的图片文件夹下有stars_0.gif这张图片哦)

原文链接:https://www.abaoge.com/post/389.html,转载请注明出处。

0

评论0

没有账号?注册  忘记密码?