本帖最后由 神马 于 2011-6-29 13:41 编辑
让产品评论直接显示在产品页下,而不需要再点一下才能看到产品评论,这个可以通过以下方法实现:
1、打开 includes/modules/pages/product_info/header_php.php,将下面的代码复制粘贴到 ?> 前- // 商品评论
- $reviews_query_raw = "SELECT r.reviews_id, left(rd.reviews_text, 100) 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();
- }
复制代码 2、在ncludes/templates/你的模板目录/templates/tpl_product_info_display.php的适当位置加入下面代码- <div class="commInfo">
- <?php if ($reviews_split->number_of_rows > 0) {if ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3')) { ?>
- <div id="productReviewsDefaultListingTopNumber" class="pagination">
- <span><?php echo $reviews_split->display_count(TEXT_DISPLAY_NUMBER_OF_REVIEWS); ?></span>
- <span>
- <?php echo TEXT_RESULT_PAGE . ' ' . $reviews_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'main_page')));?>
- </span>
- </div>
- <div class="clear"></div>
- <?php } foreach ($reviewsArray as $reviews) { ?>
- <div class="comm">
- <div class="commTitle">
- <span 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']));?>
- </span>
- <span 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']);?>
- </span>
- <div class="clear"></div>
- </div>
- <p class="productReviewsDefaultProductMainContent content">
- <?php echo zen_break_string(zen_output_string_protected(stripslashes($reviews['reviewsText'])), 60, '-<br />') . ((strlen($reviews['reviewsText']) >= 180) ? '...' : '');?>
- </p>
- <br class="clearBoth" />
- </div>
- <?php } ?>
- <?php } else { ?>
- <div class="Dashed"></div>
- <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'))) { ?>
- <div id="productReviewsDefaultListingBottomNumber" class="pagination Dashed">
- <span><?php echo $reviews_split->display_count(TEXT_DISPLAY_NUMBER_OF_REVIEWS); ?></span>
- <span class="paginator">
- <?php echo TEXT_RESULT_PAGE . ' ' . $reviews_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'main_page')));?>
- </span>
- </div>
- <div class="clear"></div>
- <?php } ?>
- </div>
复制代码 3、在includes/languages/english/你的模板目录/product_info.php的适当位置加入下面代码- define('TEXT_OF_5_STARS', '');
- define('TEXT_PRODUCT_INFO', 'Products info');
- define('TEXT_READ_REVIEW', 'Read reviews');
- define('TEXT_APPROVAL_REQUIRED', '<strong>Tips : </strong>Comments after the show audited');
- define('SUB_TITLE_FROM', 'From:');
- define('SUB_TITLE_REVIEW', 'There are currently no product reviews。');
- define('SUB_TITLE_RATING', 'Please share your views on commodities。');
- define('TEXT_NO_HTML', '<strong>Tips : </strong> Can not use the HTML || ');
- define('TEXT_BAD', 'Worst');
- define('TEXT_GOOD', 'Best');
- define('EMAIL_REVIEW_PENDING_SUBJECT','Comment is being reviewed: %s');
- define('EMAIL_PRODUCT_REVIEW_CONTENT_INTRO','Goods%sA comment is awaiting your review。'."\n\n");
- define('EMAIL_PRODUCT_REVIEW_CONTENT_DETAILS','Comment content : %s');
复制代码 不会的话,就用这里的模块:
http://www.zen-cart.cn/other-modules/dgreviews |