zencart 添加评论回复功能

用于收藏精华贴子、网友共享的资料等。可以回复,不能发新贴。

版主: Jack

版面规则
本版面不能发新贴,可以回复

zencart 添加评论回复功能

帖子lxq73061 » 2010-09-17 10:07

//SQL:
代码: 全选
ALTER TABLE `reviews_description` ADD `reviews_reply` TEXT NOT NULL


//文件:\admin\reviews.php
//功能:后台显示,修改
代码: 全选
$reviews_reply = zen_db_prepare_input($_POST['reviews_reply']);

$db->Execute("update " . TABLE_REVIEWS_DESCRIPTION . "
set reviews_text = '" . zen_db_input($reviews_text) . "',
reviews_reply = '" . zen_db_input($reviews_reply) . "'
where reviews_id = '" . (int)$reviews_id . "'");


if ($action == 'edit') {
$rID = zen_db_prepare_input($_GET['rID']);

$reviews = $db->Execute("select r.reviews_id, r.products_id, r.customers_name, r.date_added,
r.last_modified, r.reviews_read, rd.reviews_text, r.reviews_rating,rd.reviews_reply
from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd
where r.reviews_id = '" . (int)$rID . "' and r.reviews_id = rd.reviews_id");




<td class="main" valign="top"><b><?php echo ENTRY_REVIEW; ?></b><br><br>
<?php echo zen_draw_textarea_field('reviews_text', 'soft', '70', '15', stripslashes($rInfo->reviews_text)); ?>
<?php echo zen_draw_textarea_field('reviews_reply', 'soft', '70', '15', stripslashes($rInfo->reviews_reply)); ?>
</td>



} elseif ($action == 'preview') {
if (zen_not_null($_POST)) {
$rInfo = new objectInfo($_POST);
} else {
$rID = zen_db_prepare_input($_GET['rID']);

$reviews = $db->Execute("select r.reviews_id, r.products_id, r.customers_name, r.customers_email,r.customers_ip, r.date_added,
r.last_modified, r.reviews_read, rd.reviews_text,rd.reviews_reply,
r.reviews_rating
from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd
where r.reviews_id = '" . (int)$rID . "'
and r.reviews_id = rd.reviews_id");



<td class="main"><b><?php echo ENTRY_RATING; ?></b>&nbsp;<?php echo zen_image(DIR_WS_TEMPLATE_IMAGES . 'stars_' . $rInfo->reviews_rating . '.gif', sprintf

(TEXT_OF_5_STARS, $rInfo->reviews_rating)); ?>&nbsp;<small>[<?php echo sprintf(TEXT_OF_5_STARS, $rInfo->reviews_rating); ?>]</small>
<?php if($rInfo->reviews_reply!= null){?>
<?php echo '<br /><DIV class="reviews_reply"><b>Reply:</b> '.nl2br(zen_db_output(zen_break_string($rInfo->reviews_reply,15))).'</DIV>'?>
<?php }?>

</td>







//文件:\includes\modules\pages\product_reviews_write\header_php.php
//功能:保存客户IP,客户EMAIL(修正原版本BUG)
代码: 全选
$customers_ip =   $_SESSION['customers_ip_address'];



$sql = "INSERT INTO " . TABLE_REVIEWS . " (products_id, customers_id,customers_email,review_title,customers_name, reviews_rating, date_added, status,customers_ip)
VALUES (:productsID, :customersID,:customers_email,:review_title, :customersName, :rating, now(), " . $review_status . ",:customers_ip)";

$sql = $db->bindVars($sql, ':productsID', $_GET['products_id'], 'integer');
$sql = $db->bindVars($sql, ':customersID', (isset($_SESSION['customer_id']) || $_SESSION['customer_id']=="")?0:$_SESSION['customer_id'], 'integer');
// $sql = $db->bindVars($sql, ':customersName', $customer->fields['customers_firstname'] . ' ' . $customer->fields['customers_lastname'], 'string');
$sql = $db->bindVars($sql, ':customers_email', $customer_email, 'string');
$sql = $db->bindVars($sql, ':review_title', $review_title, 'string');
$sql = $db->bindVars($sql, ':customersName',$customer_name, 'string');
$sql = $db->bindVars($sql, ':rating', $rating, 'string');
$sql = $db->bindVars($sql, ':customers_ip', $customers_ip, 'string');

$db->Execute($sql);





//文件:\includes\templates\ezppt\templates\tpl_product_reviews_default.php
//功能:显示reviews_reply内容
代码: 全选
<br />
<?php if($reviews['reviewsReply'] != null){?>
<?php echo '<DIV class="reviews_reply">Reply: '.$reviews['reviewsReply'] .'</DIV>'?>
<?php }?>





//文件:\includes\modules\pages\product_info\header_php.php
//功能:读取reviews_reply字段并赋值

代码: 全选
$reviews_query_raw = "SELECT r.reviews_id, left(rd.reviews_text, 400) as reviews_text, r.reviews_rating, r.date_added, r.customers_name,rd.reviews_reply                       

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'],
'reviewsReply'=>$reviews->fields['reviews_reply'],//@steven added
'reviewsRating'=>$reviews->fields['reviews_rating']);
$reviews->MoveNext();
}


//注意,以上代码并非连续的,请在适当位置进行修改.
引用:http://hi.baidu.com/lxq73061/blog/item/3245470f1f5f83246059f3da.html
附件
外贸建站,模板开发,联系:lxq73061@qq.com www.520sz.com
lxq73061
普通会员
普通会员
 
帖子: 44
注册: 2009-06-06 22:06
QQ 帐号: 583964941

Re: zencart 添加评论回复功能

帖子zencart201039 » 2010-09-17 10:35

好东西,不错,我也来用用。感谢楼主分享!
ZenCart模板|Magento模板 |zencart建站|强创网络工作室 www.51qcweb.com
zencart201039
普通会员
普通会员
 
帖子: 33
注册: 2010-08-02 19:44
地址: 本人从事zencart,magento网站建设,要做模板的人可以联系我,博客:www.51qcweb.com
QQ 帐号: 827249565

Re: zencart 添加评论回复功能

帖子lxq73061 » 2010-09-17 11:05

外贸建站,模板开发,联系:lxq73061@qq.com www.520sz.com
lxq73061
普通会员
普通会员
 
帖子: 44
注册: 2009-06-06 22:06
QQ 帐号: 583964941

Re: zencart 添加评论回复功能

帖子kira » 2010-09-17 20:34

收藏一下
头像
kira
VIP会员
VIP会员
 
帖子: 1398
注册: 2010-03-06 11:38
QQ 帐号: 6171718

Re: zencart 添加评论回复功能

帖子kin222 » 2010-09-18 10:35

好象不错,先谢了
kin222
普通会员
普通会员
 
帖子: 32
注册: 2010-06-12 14:50

Re: zencart 添加评论回复功能

帖子Pires07 » 2010-09-21 13:57

对于最后一段程序,我的源文件是这样的,请问在何处修改,如何修改???

$zco_notifier->notify('NOTIFY_HEADER_START_PRODUCT_INFO');

require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
if ($_POST['action']){
if (REVIEWS_APPROVAL == '1') {
$review_status = '0';
} else {
$review_status = '1';
}
$sql_data_array =array();
$sql_data_array2 =array();
$customer_id = isset($_SESSION['customer_id']) ? $_SESSION['customer_id']:'';
$reviews_rating = $_POST['product_score'];
$customer_name = isset($_SESSION['customer_id']) ? zen_get_customer_name($_SESSION['customer_id']):$_POST['customer_name'];
$customer_email = isset($_SESSION['customer_id']) ? zen_get_customer_email($_SESSION['customer_id']):$_POST['customer_email'];
$review_title = $_POST['review_title'];
$review_content = $_POST['review_content'];
$sql = "INSERT INTO " . TABLE_REVIEWS . " (products_id, customers_id, customers_name, customers_email, reviews_rating, date_added, status)
VALUES (:productsID, :customersID, :customersName, :customersEmail, :rating, now(), " . $review_status . ")";


$sql = $db->bindVars($sql, ':productsID', $_GET['products_id'], 'integer');
$sql = $db->bindVars($sql, ':customersID', $customer_id, 'integer');
$sql = $db->bindVars($sql, ':customersName', $customer_name, 'string');
$sql = $db->bindVars($sql, ':customersEmail', $customer_email, 'string');
$sql = $db->bindVars($sql, ':rating', $reviews_rating, 'string');

$db->Execute($sql);
$insert_id = $db->insert_ID();
$sql = "INSERT INTO " . TABLE_REVIEWS_DESCRIPTION . " (reviews_id, languages_id, reviews_text, reviews_title)
VALUES (:insertID, :languagesID, :reviewText, :reviews_title)";

$sql = $db->bindVars($sql, ':insertID', $insert_id, 'integer');
$sql = $db->bindVars($sql, ':languagesID', $_SESSION['languages_id'], 'integer');
$sql = $db->bindVars($sql, ':reviewText', $review_content, 'string');
$sql = $db->bindVars($sql, ':reviews_title', $review_title, 'string');

$db->Execute($sql);

$messageStack->add('reviews',TEXT_WRITE_REVIEW_SUCCESS,'success');
unset($_POST);
}
// if specified product_id is disabled or doesn't exist, ensure that metatags and breadcrumbs don't share inappropriate information
$sql = "select count(*) as total
from " . TABLE_PRODUCTS . " p, " .
TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_status = '1'
and p.products_id = '" . (int)$_GET['products_id'] . "'
and pd.products_id = p.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
$res = $db->Execute($sql);
if ( $res->fields['total'] < 1 ) {
unset($_GET['products_id']);
unset($breadcrumb->_trail[sizeof($breadcrumb->_trail)-1]['title']);
header('HTTP/1.1 404 Not Found');
}

// ensure navigation snapshot in case must-be-logged-in-for-price is enabled
if (!$_SESSION['customer_id']) {
$_SESSION['navigation']->set_snapshot();
}

/*
* This is Payment Info Popup
*/
$paymentInfoString = '<dl class="dl_dot pad_10px">';
$file_extension = '.php';
$key_value = $db->Execute("select configuration_value
from " . TABLE_CONFIGURATION . "
where configuration_key = 'MODULE_PAYMENT_INSTALLED'");
$paymentArray = explode(';',$key_value->fields['configuration_value']);
$module_directory = DIR_WS_MODULES . 'payment/';
$directory_array = array();
if ($dir = @dir($module_directory)) {
while ($file = $dir->read()) {
if (!is_dir($module_directory . $file)) {
if (substr($file, strrpos($file, '.')) == $file_extension) {
$directory_array[] = $file;
}
}
}
sort($directory_array);
$dir->close();
}
$paymentNum = count($directory_array);
for($i=0 ; $i<$paymentNum; $i++) {
if(in_array($directory_array[$i],$paymentArray)){
$file = $directory_array[$i];
include(DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $file);
include($module_directory . $file);
$class = substr($file, 0, strrpos($file, '.'));
if (zen_class_exists($class)) {
$module = new $class;
$paymentInfoString .= '<dt>'.$module->title.'</dt>';
}
}
}
$paymentInfoString .= '</dl>';
/*
* This is Shipping Cost Program
*/
$num_zones = 3;
$countriesIds = array();
$countriesStr1 = array();
$countriesStr2 = array();
$countriesId = $db->Execute("SELECT countries_id,countries_iso_code_2 FROM ". TABLE_COUNTRIES);
if ($countriesId->RecordCount()>0){
while (!$countriesId->EOF){
$countriesIds[$countriesId->fields['countries_iso_code_2']] = $countriesId->fields['countries_id'];
$countriesId->MoveNext();
}
}
function codeToId(&$code, $key){
global $countriesIds;
$code = $countriesIds[$code];
}
for ($i = 1; $i <= $num_zones; $i++) {
if (defined('MODULE_SHIPPING_STANDARD_COUNTRIES_' . $i)) {

$countries_table = constant('MODULE_SHIPPING_STANDARD_COUNTRIES_' . $i);

if (defined('MODULE_SHIPPING_STANDARD_COST_' . $i)) {

$cost_table = constant('MODULE_SHIPPING_STANDARD_COST_' . $i);
$countries_table = strtoupper(str_replace(' ', '', $countries_table));
$country_zones = split("[,]", $countries_table);
if ($country_zones[0] != '00'){
array_walk($country_zones,'codeToId');
}
if ($countries_table !=''){
$countriesStr1[$i]= implode(',',$country_zones).'|'.$cost_table;
}
} else {

}
} else {

}
}

for ($i = 1; $i <= $num_zones; $i++) {
if (defined('MODULE_SHIPPING_EXPEDITED_COUNTRIES_' . $i)) {

$countries_table = constant('MODULE_SHIPPING_EXPEDITED_COUNTRIES_' . $i);

if (defined('MODULE_SHIPPING_EXPEDITED_COST_' . $i)) {

$cost_table = constant('MODULE_SHIPPING_EXPEDITED_COST_' . $i);

$countries_table = strtoupper(str_replace(' ', '', $countries_table));
$country_zones = split("[,]", $countries_table);
if ($country_zones[0] != '00'){
array_walk($country_zones,'codeToId');
}
if ($countries_table !=''){
$countriesStr2[$i]= implode(',',$country_zones).'|'.$cost_table;
}
} else {
define('MODULE_SHIPPING_EXPEDITED_COST_NOT_SET_' . $i, true);
}
} else {
define('MODULE_SHIPPING_EXPEDITED_COUNTRIES_NOT_SET' . $i, true);
}
}
$standard = (implode('-',$countriesStr1));

if (defined('MODULE_SHIPPING_STANDARD_SKIPPED')) {
$standardSkip = constant('MODULE_SHIPPING_STANDARD_SKIPPED');
$standardSkipArray = explode(',',$standardSkip);
array_walk($standardSkipArray,'codeToId');
$standardSkipStr = implode(',',$standardSkipArray);
} else {

}

$expedited = (implode('-',$countriesStr2));

if (defined('MODULE_SHIPPING_EXPEDITED_SKIPPED')) {
$expeditedSkip =constant('MODULE_SHIPPING_EXPEDITED_SKIPPED');
$expeditedSkipArray = explode(',',$expeditedSkip);
array_walk($expeditedSkipArray,'codeToId');
$expeditedSkipStr = implode(',',$expeditedSkipArray);
} else {
define('MODULE_SHIPPING_EXPEDITED_SKIPPED_NOT_SET', true);
}
/*
* End Shipping Cost
*/
require(DIR_WS_CLASSES . 'order.php');
$order = new order;
$selected_country = $order->delivery['country']['id'];

// This should be last line of the script:
$zco_notifier->notify('NOTIFY_HEADER_END_PRODUCT_INFO');
?>
Pires07
普通会员
普通会员
 
帖子: 33
注册: 2009-12-09 13:45

Re: zencart 添加评论回复功能

帖子Pires07 » 2010-09-22 21:13

Jack , 能指教一下吗?
Pires07
普通会员
普通会员
 
帖子: 33
注册: 2009-12-09 13:45

Re: zencart 添加评论回复功能

帖子lxq73061 » 2010-09-23 9:28

这个教程并不是完全的傻瓜教程,希望对zencart代码能够看的懂些的人来修改,要不改不好又来问我很麻烦,
另外,后面我已经为这个功能加上了验证码功能。

[zencart添加留言验证码功能] http://hi.baidu.com/lxq73061/blog/item/71e72b6dd27ac8f5431694fd.html
附件
外贸建站,模板开发,联系:lxq73061@qq.com www.520sz.com
lxq73061
普通会员
普通会员
 
帖子: 44
注册: 2009-06-06 22:06
QQ 帐号: 583964941

Re: zencart 添加评论回复功能

帖子stravas » 2010-09-23 14:12

非常感谢,很好用..教程写的很明了.容易看出哪儿改动..多谢.
stravas
中级会员
中级会员
 
帖子: 75
注册: 2009-02-23 23:51

Re: zencart 添加评论回复功能

帖子Pires07 » 2010-09-23 15:31

stravas 写道:非常感谢,很好用..教程写的很明了.容易看出哪儿改动..多谢.


最后一步,怎么改哦?
Pires07
普通会员
普通会员
 
帖子: 33
注册: 2009-12-09 13:45

下一页

  • 相关话题
    回复总数
    阅读次数
    最新文章

回到 精华共享



在线用户

正在浏览此版面的用户:没有注册用户 和 0 位游客

cron