首 页  >>  E商学院  >>  zencart百科  >>  商品页增加评论

商品页增加评论

Zen
Cart 商品页默认只有评论链接铵钮 没有直接调用对应的商品评论,
有的时候 出于SEO的需求,
希望将商品评论直接调用在商品页展示,
这样当有新评论增加的时候, 商品页既被视为更新的页面,
这对 SEO 是相当有利的, 之前
曾在中文社区发过方法,
这里再原封不动的搬过来, 以备后用.


第一步:
打开 includes/modules/pages/product_info/header_php.php
下面代码复制到
?> 前








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20


// 商品评论 $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(); }


打开
includes/templates/你的模板目录/templates/tpl_product_info_display.php
在适当位置加入下面代码








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49


 <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']));?>&nbsp; <?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>


打开 includes/languages/english/你的模板目录/product_info.php
在适当位置加入下面代码








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16


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');


至此 商品页面添加评论 的修改结束
通过上面的修改 即可以把当前与该商品相关的评论调用在具体的商品页面展示
如果 想把
撰写评论文本框也放置在商品页展示
则把下面这句 放在
includes/templates/你的模板目录/templates/tpl_product_info_display.php 适当的位置 上即可








1


<?php require($template->get_template_dir('/tpl_product_reviews_write_default.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_product_reviews_write_default.php'); ?>


小提示:
一 上面的修改 只实现功能, 具体的样式 需要针对实际应用的模板自己调整

上面描述中 的 适当位置 为 为自己想用于展示这个功能区块的实际位置


点击次数:7124  发布日期:2013-04-15  【打印此页】  【关闭