如何让zen cart商品评论显示在商品详情页面上
答案:2 悬赏:10 手机版
解决时间 2021-04-06 22:57
- 提问者网友:wodetian
- 2021-04-06 08:51
如何让zen cart商品评论显示在商品详情页面上
最佳答案
- 五星知识达人网友:蓝房子
- 2021-04-06 10:09
操作步骤如下(请注意备份文件,不代表100%成功,意外发生,责任自负):
A. 从\includes\modules\pages\product_reviews\product_reviews page,这里复制以下代码至\includes\modules\pages\product_info\header_php.php中(注意要放在PHP代 码里面)
$reviews_query_raw = "SELECt r.reviews_id, left(rd.reviews_text, 300) as reviews_text, r.reviews_rating, r.date_added, r.customers_name
FROM " . TABLE_REVIEWS ." r, " . TABLE_REVIEWS_DESCRIPTION . " rd
WHERe r.products_id = :productsID
AND r.reviews_id = rd.reviews_id
AND rd.languages_id = :languagesID ". $review_status . "
ORDER BY r.reviews_id desc";
$reviews_query_raw = $db->bindVars($reviews_query_raw, ':productsID', $_GET['products_id'],'integer');
$reviews_query_raw = $db->bindVars($reviews_query_raw,':languagesID', $_SESSION['languages_id'], 'integer');
$reviews_split = new splitPageResults($reviews_query_raw, MAX_DISPLAY_NEW_REVIEWS);
$reviews = $db->Execute($reviews_split->sql_query);
$reviewsArray = array();
while (!$reviews->EOF) {
$reviewsArray[] = array(’id’=>$reviews->fields['reviews_id'],
'customersName'=>$reviews->fields['customers_name'],
'dateAdded'=>$reviews->fields['date_added'],
'reviewsText'=>$reviews->fields['reviews_text'],
'reviewsRating'=>$reviews->fields['reviews_rating']);
$reviews->MoveNext();
}
B. 从这里\includes\templates\YOUR_TEMPLATE_NAME\templates \tpl_product_reviews_default.php复制以下以下代码至:\includes\templates\CUSTOM \templates\tpl_product_info_display.php
if ($reviews_split->number_of_rows > 0) {
if ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3')) {
?>
}
foreach ($reviewsArray as $reviews) {
?>
}
?>
} else {
?>
}
if (($reviews_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>
}
?>
if ($flag_show_product_info_reviews == 1) {
// if more than 0 reviews, then show reviews button; otherwise, show the "write review" button
if ($reviews->fields['count'] > 0 ) { ?>
}
}
?>
3. 大功完成80%,TEXT_OF_5_STARS这样显示不太好,所以最后让我们来完善语言项,找到语言文件includes/languages/english/product_info.php的结尾处加入代码:
//bof product reviews
define('TEXT_OF_5_STARS', '%s of 5 Stars');
//eof product reviews
4. 大功告成,刷新看看效果吧。
A. 从\includes\modules\pages\product_reviews\product_reviews page,这里复制以下代码至\includes\modules\pages\product_info\header_php.php中(注意要放在PHP代 码里面)
$reviews_query_raw = "SELECt r.reviews_id, left(rd.reviews_text, 300) as reviews_text, r.reviews_rating, r.date_added, r.customers_name
FROM " . TABLE_REVIEWS ." r, " . TABLE_REVIEWS_DESCRIPTION . " rd
WHERe r.products_id = :productsID
AND r.reviews_id = rd.reviews_id
AND rd.languages_id = :languagesID ". $review_status . "
ORDER BY r.reviews_id desc";
$reviews_query_raw = $db->bindVars($reviews_query_raw, ':productsID', $_GET['products_id'],'integer');
$reviews_query_raw = $db->bindVars($reviews_query_raw,':languagesID', $_SESSION['languages_id'], 'integer');
$reviews_split = new splitPageResults($reviews_query_raw, MAX_DISPLAY_NEW_REVIEWS);
$reviews = $db->Execute($reviews_split->sql_query);
$reviewsArray = array();
while (!$reviews->EOF) {
$reviewsArray[] = array(’id’=>$reviews->fields['reviews_id'],
'customersName'=>$reviews->fields['customers_name'],
'dateAdded'=>$reviews->fields['date_added'],
'reviewsText'=>$reviews->fields['reviews_text'],
'reviewsRating'=>$reviews->fields['reviews_rating']);
$reviews->MoveNext();
}
B. 从这里\includes\templates\YOUR_TEMPLATE_NAME\templates \tpl_product_reviews_default.php复制以下以下代码至:\includes\templates\CUSTOM \templates\tpl_product_info_display.php
if ($reviews_split->number_of_rows > 0) {
if ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3')) {
?>
}
foreach ($reviewsArray as $reviews) {
?>
') . ((strlen($reviews['reviewsText']) >= 100) ? '...' : ''); ?>
}
?>
} else {
?>
' . TEXT_APPROVAL_REQUIRED: ''); ?>
}
if (($reviews_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>
}
?>
if ($flag_show_product_info_reviews == 1) {
// if more than 0 reviews, then show reviews button; otherwise, show the "write review" button
if ($reviews->fields['count'] > 0 ) { ?>
fields['count'] : ''); ?>
}
}
?>
3. 大功完成80%,TEXT_OF_5_STARS这样显示不太好,所以最后让我们来完善语言项,找到语言文件includes/languages/english/product_info.php的结尾处加入代码:
//bof product reviews
define('TEXT_OF_5_STARS', '%s of 5 Stars');
//eof product reviews
4. 大功告成,刷新看看效果吧。
全部回答
- 1楼网友:愁杀梦里人
- 2021-04-06 10:33
首先找到zencart文件,在 includes/templates/你的模板目录/templates/下面创建一个文件 命名为tpl_product_info_similar.php 当然,也可以随便命名,把以下代码复制进去, related products
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯