修改前请备份数据库和相关文件。
第一步:修改数据库
进入数据库 找到 ecs_comment,前缀修改过的,当然就不是这个表了,
在 content<----> text<----> utf8_general_ci
这个字段后 加上两个字段
content2<----> text<----> utf8_general_ci
content3 <---->text<----> utf8_general_ci
我这里将以原来的
email <----> varchar(60)
这个字段为标题字段,当然你也可以再新加一个作为标题字段
这样我现在的这个字段说明分别是:
email - 标题 content - 总结 content2 优点 content3-不足
第二步:修改 includes/lib_main.php
找到大概1586行:(红色为添加部分)
$ids .= $ids ? ",$row[comment_id]" : $row['comment_id'];
$arr[$row['comment_id']]['id'] = $row['comment_id'];
$arr[$row['comment_id']]['email'] = $row['email'];
$arr[$row['comment_id']]['username'] = $row['user_name'];
$arr[$row['comment_id']]['content2'] = str_replace('/r/n', '<br />', htmlspecialchars($row['content2'])); //tc
$arr[$row['comment_id']]['content3'] = str_replace('/r/n', '<br />', htmlspecialchars($row['content3'])); //tc
$arr[$row['comment_id']]['content'] = str_replace('/r/n', '<br />', htmlspecialchars($row['content']));
$arr[$row['comment_id']]['content'] = str_replace('/n', '<br />', $arr[$row['comment_id']]['content']);
$arr[$row['comment_id']]['rank'] = $row['comment_rank'];
第三步:修改 /comment.php
1)找到大概247行:(红色为添加部分)
$smarty->assign('comment_type', $cmt->type);
$smarty->assign('id', $cmt->id);
$smarty->assign('content2', $cmt->content2); //tc
$smarty->assign('content3', $cmt->content3); //tc
$smarty->assign('username', $_SESSION['user_name']);
$smarty->assign('email', $_SESSION['email']);
2)找到大概 290行,将下面这块代码 替换掉 原有的代码
/* 保存评论内容 */
$sql = "INSERT INTO " .$GLOBALS['ecs']->table('comment') .
"(comment_type, id_value, email, user_name, content,content2,content3, comment_rank, add_time, ip_address, status, parent_id, user_id) VALUES " .
"('" .$cmt->type. "', '" .$cmt->id. "', '".$cmt->email."', '$user_name', '" .$cmt->content."','".$cmt->content2."','".$cmt->content3."', '".$cmt->rank."', ".gmtime().", '".real_ip()."', '$status', '0', '$user_id')";
最后一步:显示页面,修改themes/360/library/comments_list.lib
替换下面关键代码。
... <div>
<ul>
<!-- {if $comments} -->
<!-- {foreach from=$comments item=comment} -->
<li style="border-bottom:#ccc 1px dashed;">
<font>
<!-- {if $comment.username} -->{$comment.username|escape:html}<!-- {else} -->{$lang.anonymous}<!-- {/if} -->
</font> ( {$comment.add_time} ) <font style="font-size:14px; font-weight:bold; color:#336699">{$comment.email}</font><br />
<img src="../images/stars{$comment.rank}.gif" alt="{$comment.comment_rank}" />
<p><font color="#FF9900">优点:</font>{$comment.content2}<br>
<font color="#FF9900">不足:</font>{$comment.content3}<br>
<font color="#FF9900">总结:</font>{$comment.content}</p>
<!-- {if $comment.re_content} -->
<p>
<font>{$lang.admin_username}</font><br>
{$comment.re_content}
</p>
<!-- {/if} -->
</li>
<!-- {/foreach} -->
<!--{else}-->
<li>{$lang.no_comments}</li>
<!--{/if}-->
</ul>
....
<script type="Text/Javascript" language="JavaScript">
<!--
{literal}
function selectPage(sel)
{
sel.form.submit();
}
{/literal}
//-->
</script>
</div>
<!--翻页 END-->
<!--评论表单 start-->
<div>
<form action="javascript:;" onsubmit="submitComment(this)" method="post" name="commentForm" id="commentForm">
<table border="0" cellspacing="5" cellpadding="0" style="background:#FFF;">
<tr>
<td width="211" align="left" style="font-size:14px; font-weight:bold;">发表评价并打分:</td>
<td style="display:none" {if !$enabled_captcha}{/if}><!--{if $smarty.session.user_name}-->{$smarty.session.user_name}<!--{else}-->{$lang.anonymous}<!--{/if}--></td>
</tr>
<tr>
<td align="right">标题:</td>
<td>
<input type="text" name="email" id="email" style="width:420px;" maxlength="100" value=""/>
</td>
</tr>
<tr>
<td align="right">{$lang.comment_rank}:</td>
<td>
<input name="comment_rank" type="radio" value="1" id="comment_rank1" /> <img src="../images/stars1.gif" />
<input name="comment_rank" type="radio" value="2" id="comment_rank2" /> <img src="../images/stars2.gif" />
<input name="comment_rank" type="radio" value="3" id="comment_rank3" /> <img src="../images/stars3.gif" />
<input name="comment_rank" type="radio" value="4" id="comment_rank4" /> <img src="../images/stars4.gif" />
<input name="comment_rank" type="radio" value="5" checked="checked" id="comment_rank5" /> <img src="../images/stars5.gif" />
</td>
</tr>
<tr>
<td align="right" valign="top">您认为该商品的优点是:</td>
<td><textarea name="content2" style="height:50px; width:520px;"></textarea></td>
</tr>
<tr>
<td align="right" valign="top">您认为该商品的不足是:</td>
<td><textarea name="content3" style="height:50px; width:520px;">暂时还没发现缺点哦!</textarea></td>
</tr>
<tr>
<td align="right" valign="top">总结:</td>
<td>
<textarea name="content" style="height:50px; width:520px;"></textarea>
<input type="hidden" name="cmt_type" value="{$comment_type}" />
<input type="hidden" name="id" value="{$id}" />
</td>
</tr>
<tr>
<td colspan="2">
<!-- 判断是否启用验证码{if $enabled_captcha} -->
....
<script type="text/javascript">
//<![CDATA[
{foreach from=$lang.cmt_lang item=item key=key}
var {$key} = "{$item}";
{/foreach}
{literal}
/**
* 提交评论信息
*/
function submitComment(frm)
{
var cmt = new Object;
//cmt.username = frm.elements['username'].value;
cmt.email = frm.elements['email'].value;
cmt.content = frm.elements['content'].value;
cmt.content2 = frm.elements['content2'].value;
cmt.content3 = frm.elements['content3'].value;
cmt.type = frm.elements['cmt_type'].value;
cmt.id = frm.elements['id'].value;
cmt.enabled_captcha = frm.elements['enabled_captcha'] ? frm.elements['enabled_captcha'].value : '0';
cmt.captcha = frm.elements['captcha'] ? frm.elements['captcha'].value : '';
cmt.rank = 0;
for (i = 0; i < frm.elements['comment_rank'].length; i++)
{
if (frm.elements['comment_rank'][i].checked)
{
cmt.rank = frm.elements['comment_rank'][i].value;
}
}
// if (cmt.username.length == 0)
// {
// alert(cmt_empty_username);
// return false;
// }
/*
if (cmt.email.length > 0)
{
if (!(Utils.isEmail(cmt.email)))
{
alert(cmt_error_email);
return false;
}
}
else
{
alert(cmt_empty_email);
return false;
}
*/
if (cmt.email.length == 0)
{
alert('请输入评论标题!');
return false;
}
if (cmt.content.length == 0)
{
alert(cmt_empty_content);
return false;
}
if (cmt.content2.length == 0)
{
alert(cmt_empty_content);
return false;
}
if (cmt.content3.length == 0)
{
alert(cmt_empty_content);
return false;
}
if (cmt.enabled_captcha > 0 && cmt.captcha.length == 0 )
{
alert(captcha_not_null);
return false;
}
Ajax.call('comment.php', 'cmt=' + cmt.toJSONString(), commentResponse, 'POST', 'JSON');
return false;
}
.....
新闻热点
疑难解答