如何让zen cart商品评论显示在商品详情页面上

 我来答
匿名用户
2015-02-14
展开全部
操作步骤如下(请注意备份文件,本文在1.38a版本测试通过,但不代表100%成功,意外发生,责任自负):
A,从includesmodulespagesproduct_reviewsproduct_reviews page,这里复制以下代码至includesmodulespagesproduct_infoheader.php中(注意要放在PHP代码里面.)
$review_status = ” AND r.status = 1″;
$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”;
一骑当后
推荐于2016-06-06 · 知道合伙人数码行家
一骑当后
知道合伙人数码行家
采纳数:40298 获赞数:306440
网络、设备维护、电路、弱电检测。

向TA提问 私信TA
展开全部
操作步骤如下(请注意备份文件,不代表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
<!--bof Reviews button and count-->

<!--
<h1 id="productReviewsDefaultHeading"><?php echo $products_name . $products_model; ?></h1>

<h2 id="productReviewsDefaultPrice" class=""><?php echo $products_price; ?></h2>
-->
<br class="clearBoth" />
<h1><?php echo $products_name ."的所有评论";?></h1>
<?php
if ($reviews_split->number_of_rows > 0) {
if ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3')) {
?>

<div id="productReviewsDefaultListingTopNumber" class="navSplitPagesResult"><?php echo $reviews_split->display_count(TEXT_DISPLAY_NUMBER_OF_REVIEWS); ?></div>

<div id="productReviewsDefaultListingTopLinks" class="navSplitPagesLinks"><?php echo TEXT_RESULT_PAGE . ' ' . $reviews_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'main_page'))); ?></div>

<?php
}
foreach ($reviewsArray as $reviews) {
?>
<hr />
<!--
<div class="buttonRow forward"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . (int)$_GET['products_id'] . '&reviews_id=' . $reviews['id']) . '">' . zen_image_button(BUTTON_IMAGE_READ_REVIEWS , BUTTON_READ_REVIEWS_ALT) . '</a>'; ?></div>
-->
<div class="productReviewsDefaultReviewer bold"><?php echo sprintf(TEXT_REVIEW_DATE_ADDED, zen_date_short($reviews['dateAdded'])); ?> <?php echo sprintf(TEXT_REVIEW_BY, zen_output_string_protected($reviews['customersName'])); ?></div>

<div class="rating"><?php echo zen_image(DIR_WS_TEMPLATE_IMAGES . 'stars_' . $reviews['reviewsRating'] . '.gif', sprintf(TEXT_OF_5_STARS, $reviews['reviewsRating'])), sprintf(TEXT_OF_5_STARS, $reviews['reviewsRating']); ?></div>

<div class="productReviewsDefaultProductMainContent content"><?php echo zen_break_string(zen_output_string_protected(stripslashes($reviews['reviewsText'])), 60, '-<br />') . ((strlen($reviews['reviewsText']) >= 100) ? '...' : ''); ?></div>

<br class="clearBoth" />
<?php
}
?>
<?php
} else {
?>
<hr />
<div id="productReviewsDefaultNoReviews" class="content"><?php echo TEXT_NO_REVIEWS . (REVIEWS_APPROVAL == '1' ? '<br />' . TEXT_APPROVAL_REQUIRED: ''); ?></div>
<br class="clearBoth" />
<?php
}

if (($reviews_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>
<hr />
<div id="productReviewsDefaultListingBottomNumber" class="navSplitPagesResult"><?php echo $reviews_split->display_count(TEXT_DISPLAY_NUMBER_OF_REVIEWS); ?></div>
<div id="productReviewsDefaultListingBottomLinks" class="navSplitPagesLinks"><?php echo TEXT_RESULT_PAGE . ' ' . $reviews_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'main_page'))); ?></div>

<?php
}
?>
<?php

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 ) { ?>
<div id="productReviewLink" class="buttonRow back">
<?php echo '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS, zen_get_all_get_params()) . '">' . zen_image_button(BUTTON_IMAGE_REVIEWS, BUTTON_REVIEWS_ALT) . '</a>'; ?>
</div>
<br class="clearBoth" />
<p class="reviewCount"><?php echo ($flag_show_product_info_reviews_count == 1 ? TEXT_CURRENT_REVIEWS . ' ' . $reviews->fields['count'] : ''); ?></p>
<?php } else { ?>
<div id="productReviewLink" class="buttonRow back"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, zen_get_all_get_params(array())) . '">' . zen_image_button(BUTTON_IMAGE_WRITE_REVIEW, BUTTON_WRITE_REVIEW_ALT) . '</a>'; ?></div>
<br class="clearBoth" />
<?php
}
}
?>
<!--eof Reviews button and 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. 大功告成,刷新看看效果吧。
本回答被提问者和网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式