JTBC(php版):三步实现模块调用评论功能且不显示隐藏评论修改
作者:我就是个世界
发表于:2011-01-24
[b]第一步:[/b]
在栏目下的index.php中加入如下语句
[code]require('../support/review/common/api/review.inc.php');[/code]
[b]第二步:[/b]
在模板管理内输入: "模块名.tpl.module" 对 "detail" 节点进行修改,在需要调用显示评论框的的位置加入:
[code]{$=ap_review_input_form($GLOBALS['ngenre'] , $_GET['id'])}[/code]
这样,就带有评论功能了,如果需要,还可以显示出前几条评论内容,调用方法如下[separator]
[code]{$=ap_review_output_note($GLOBALS['ngenre'] , $_GET['id'], 5)}[/code]
[b]函数的参数说明:[/b]
[quote]
ap_review_input_form($GLOBALS['ngenre'] , $_GET['id'])
关键字,对应ID
ap_review_output_note($GLOBALS['ngenre'] , $_GET['id'], 5)
关键字,对应ID,前N条记录
[/quote]
[b]第三步:[/b]
在\support\review\common\api\review.inc.php 第19行修改:
[code]$tsqlstr = "select * from $tdatabase where " . ii_cfnames($tfpre, 'keyword') . "='$tkeyword' and " . ii_cfnames($tfpre, 'fid') . "=$tfid order by " . ii_cfnames($tfpre, 'time') . " desc limit 0,$ttopx";[/code]
为:
[code]$tsqlstr = "select * from $tdatabase where " . ii_cfnames($tfpre, 'keyword') . "='$tkeyword' and " . ii_cfnames($tfpre, 'fid') . "=$tfid and " . ii_cfnames($tfpre, 'hidden') . "=0 order by " . ii_cfnames($tfpre, 'time') . " desc limit 0,$ttopx";[/code]
这样在使用ap_review_output_note函数输出出前几条评论内容的时候就不会输出隐藏的评论了。
[b]注:[/b] 评论调用模板在 \support\review\common\template\api.jtbc中修改。
附带我修改好的模板:
[color=#FF0000]api.jtbc[/color]
[code]
<?xml version="1.0" encoding="utf-8"?>
<xml mode="jtbc" author="jetiben">
<configure>
<node>item</node>
<field>name,tpl_default</field>
<base>item_list</base>
</configure>
<item_list>
<item>
<name><![CDATA[input_form]]></name>
<tpl_default><![CDATA[
<div class="review">
<div class="h3_tt">
<h3><img src="{$=#global_images_route}public/small/sico.gif" border="0" /> <strong><a href="{$=ii_get_actual_route(AP_SUPPORT_REVIEW_GENRE)}/?type=list&keyword={$keyword}&fid={$fid}" target="_blank"><span class="c-f60">{$=ii_itake('global.' . AP_SUPPORT_REVIEW_GENRE . ':api.view', 'lng')}</span></a></strong></h3>
</div>
<div class="h3_ct">
<form name="form" method="post" action="{$=ii_get_actual_route(AP_SUPPORT_REVIEW_GENRE)}/index.php?action=add&keyword={$keyword}&fid={$fid}&backurl={$=urlencode($GLOBALS['nurl'])}">
<table cellpadding="0" cellspacing="0" class="tablen">
<tr>
<td width="80" height="25">{$=ii_itake('global.' . AP_SUPPORT_REVIEW_GENRE . ':config.content', 'lng')}</td>
<td><textarea rows="5" name="content" cols="75" class="textarea"></textarea></td>
</tr>
<tr>
<td height="35"></td>
<td><input type="submit" name="submit" value="{$=ii_itake('global.lng_config.submit','lng')}" class="button"> <input type="reset" name="reset" value="{$=ii_itake('global.lng_config.reset','lng')}" class="button"></td>
</tr>
</table>
</form>
</div>
</div>
]]></tpl_default>
</item>
<item>
<name><![CDATA[output_note]]></name>
<tpl_default><![CDATA[
<div class="review">{@recurrence_ida}
<div class="h3_tt">
<h3><img src="{$=#global_images_route}public/small/sico.gif" border="0" /> <strong><span class="c-f60">{$author}</span></strong></h3>
<span class="ip"> [{$=ii_format_ip(ii_htmlencode($GLOBALS['RS_authorip']), 2)}]</span>
<span class="more">{$time}</span>
</div>
<div class="h3_ct">{$content}</div>
{@recurrence_ida}
</div>
]]></tpl_default>
</item>
</item_list>
</xml>
[/code]
[color=#FF0000]css:[/color]
[code]
.h3_tt {position:relative;height:29px;border:solid #e1e1e1 1px;border-top:0;background:url(../images/h3_tt_bg.gif) repeat-x;margin-top:10px;}
.h3_tt h3 {float:left;display:inline;margin:0 15px 0 10px;font-size:12px;color:#555;line-height: 29px;}
.h3_tt .ip {position:absolute;top:5px;color:#9b9b9b;}
.h3_tt .more {position:absolute;right:10px;top:5px;color:#9b9b9b;}
.h3_tt .more a, .boxshort_commentItem .more a {font-weight:bold;text-decoration:underline;}
.h3_ct {border:solid #e1e1e1 1px;border-top:0;padding:10px;text-indent:2em;}
[/code]
在栏目下的index.php中加入如下语句
[code]require('../support/review/common/api/review.inc.php');[/code]
[b]第二步:[/b]
在模板管理内输入: "模块名.tpl.module" 对 "detail" 节点进行修改,在需要调用显示评论框的的位置加入:
[code]{$=ap_review_input_form($GLOBALS['ngenre'] , $_GET['id'])}[/code]
这样,就带有评论功能了,如果需要,还可以显示出前几条评论内容,调用方法如下[separator]
[code]{$=ap_review_output_note($GLOBALS['ngenre'] , $_GET['id'], 5)}[/code]
[b]函数的参数说明:[/b]
[quote]
ap_review_input_form($GLOBALS['ngenre'] , $_GET['id'])
关键字,对应ID
ap_review_output_note($GLOBALS['ngenre'] , $_GET['id'], 5)
关键字,对应ID,前N条记录
[/quote]
[b]第三步:[/b]
在\support\review\common\api\review.inc.php 第19行修改:
[code]$tsqlstr = "select * from $tdatabase where " . ii_cfnames($tfpre, 'keyword') . "='$tkeyword' and " . ii_cfnames($tfpre, 'fid') . "=$tfid order by " . ii_cfnames($tfpre, 'time') . " desc limit 0,$ttopx";[/code]
为:
[code]$tsqlstr = "select * from $tdatabase where " . ii_cfnames($tfpre, 'keyword') . "='$tkeyword' and " . ii_cfnames($tfpre, 'fid') . "=$tfid and " . ii_cfnames($tfpre, 'hidden') . "=0 order by " . ii_cfnames($tfpre, 'time') . " desc limit 0,$ttopx";[/code]
这样在使用ap_review_output_note函数输出出前几条评论内容的时候就不会输出隐藏的评论了。
[b]注:[/b] 评论调用模板在 \support\review\common\template\api.jtbc中修改。
附带我修改好的模板:
[color=#FF0000]api.jtbc[/color]
[code]
<?xml version="1.0" encoding="utf-8"?>
<xml mode="jtbc" author="jetiben">
<configure>
<node>item</node>
<field>name,tpl_default</field>
<base>item_list</base>
</configure>
<item_list>
<item>
<name><![CDATA[input_form]]></name>
<tpl_default><![CDATA[
<div class="review">
<div class="h3_tt">
<h3><img src="{$=#global_images_route}public/small/sico.gif" border="0" /> <strong><a href="{$=ii_get_actual_route(AP_SUPPORT_REVIEW_GENRE)}/?type=list&keyword={$keyword}&fid={$fid}" target="_blank"><span class="c-f60">{$=ii_itake('global.' . AP_SUPPORT_REVIEW_GENRE . ':api.view', 'lng')}</span></a></strong></h3>
</div>
<div class="h3_ct">
<form name="form" method="post" action="{$=ii_get_actual_route(AP_SUPPORT_REVIEW_GENRE)}/index.php?action=add&keyword={$keyword}&fid={$fid}&backurl={$=urlencode($GLOBALS['nurl'])}">
<table cellpadding="0" cellspacing="0" class="tablen">
<tr>
<td width="80" height="25">{$=ii_itake('global.' . AP_SUPPORT_REVIEW_GENRE . ':config.content', 'lng')}</td>
<td><textarea rows="5" name="content" cols="75" class="textarea"></textarea></td>
</tr>
<tr>
<td height="35"></td>
<td><input type="submit" name="submit" value="{$=ii_itake('global.lng_config.submit','lng')}" class="button"> <input type="reset" name="reset" value="{$=ii_itake('global.lng_config.reset','lng')}" class="button"></td>
</tr>
</table>
</form>
</div>
</div>
]]></tpl_default>
</item>
<item>
<name><![CDATA[output_note]]></name>
<tpl_default><![CDATA[
<div class="review">{@recurrence_ida}
<div class="h3_tt">
<h3><img src="{$=#global_images_route}public/small/sico.gif" border="0" /> <strong><span class="c-f60">{$author}</span></strong></h3>
<span class="ip"> [{$=ii_format_ip(ii_htmlencode($GLOBALS['RS_authorip']), 2)}]</span>
<span class="more">{$time}</span>
</div>
<div class="h3_ct">{$content}</div>
{@recurrence_ida}
</div>
]]></tpl_default>
</item>
</item_list>
</xml>
[/code]
[color=#FF0000]css:[/color]
[code]
.h3_tt {position:relative;height:29px;border:solid #e1e1e1 1px;border-top:0;background:url(../images/h3_tt_bg.gif) repeat-x;margin-top:10px;}
.h3_tt h3 {float:left;display:inline;margin:0 15px 0 10px;font-size:12px;color:#555;line-height: 29px;}
.h3_tt .ip {position:absolute;top:5px;color:#9b9b9b;}
.h3_tt .more {position:absolute;right:10px;top:5px;color:#9b9b9b;}
.h3_tt .more a, .boxshort_commentItem .more a {font-weight:bold;text-decoration:underline;}
.h3_ct {border:solid #e1e1e1 1px;border-top:0;padding:10px;text-indent:2em;}
[/code]
请发表您的评论