1,最近GOOGLE收录急速下降,一直在找原因,初步确定是页面相似度太高,所以加入了zen cart实现匿名评论功能,第二:修正zen cart商品评论显示太短的问题,第三就是,本文所要涉及的TPP插件引起商品详情代码重复二次的问题,考虑到SEO的因素,决定关闭TPP功能,让zen cart商品评论显示在商品详情页面,这也就是本文所写的原因.
2,操作步骤如下(请注意备份文件,本文在1.38a版本测试通过,但不代表100%成功,意外发生,责任自负):
A,从\includes\modules\pages \product_reviews\product_reviews page,这里复制以下代码至\includes\modules\pages\product_info\header.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 product reviews–>
<div id=”reviewsDefault”>
<h3 id=”productReviewsDefaultHeading”><?php echo $products_name . $products_model; ?> Reviews</h3>
<?php
if ($reviews_split->number_of_rows > 0) {
if ((PREV_NEXT_BAR_LOCATION == ‘1′) || (PREV_NEXT_BAR_LOCATION == ‘3′)) {
?>
<div id=”productReviewsDefaultListingTopNumber”><?php echo $reviews_split->display_count(TEXT_DISPLAY_NUMBER_OF_REVIEWS); ?></div>
<div id=”productReviewsDefaultListingTopLinks”><?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><?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><?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><?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><?php echo zen_break_string(zen_output_string_protected(stripslashes($reviews['reviewsText'])), 60, ‘-<br />’) . ((strlen($reviews['reviewsText']) >= 300) ? ‘…’ : ”); ?> </div>
<br />
<?php
}
?>
<?php
} else {
?>
<hr />
<div id=”productReviewsDefaultNoReviews”><?php echo TEXT_NO_REVIEWS . (REVIEWS_APPROVAL == ‘1′ ? ‘<br />’ . TEXT_APPROVAL_REQUIRED: ”); ?></div>
<br />
<?php
}
if (($reviews_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == ‘2′) || (PREV_NEXT_BAR_LOCATION == ‘3′))) {
?>
<hr />
<div id=”productReviewsDefaultListingBottomNumber”><?php echo $reviews_split->display_count(TEXT_DISPLAY_NUMBER_OF_REVIEWS); ?></div>
<div id=”productReviewsDefaultListingBottomLinks”><?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
}
?>
<div><?php echo ‘<a href=”‘ . zen_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, zen_get_all_get_params(array(’reviews_id’))) . ‘”>’ . zen_image_button(BUTTON_IMAGE_WRITE_REVIEW, BUTTON_WRITE_REVIEW_ALT) . ‘</a>’; ?><br /><div style=”font-style: italic; color: green”>for <?php echo $products_name . $products_model; ?></div></div>
</div>
<!– eof product reviews–>
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