最模板 - 外贸网站建设,外贸网站模板

最模板

当前位置: 首页 > 建站教程 > CMS教程 > DedeCMS教程 >

织梦内容页的评论功能怎么使用

时间:2014-12-24 23:57来源: 作者: 点击:
织梦程序是很强大的,在自定义模型、图集、频道等等都是自己自由的,所以如果能在文章页加上文章的评论更是锦上添花,所以很多人也想了很多的办法添加评论功能,有些人也想过

织梦程序是很强大的,在自定义模型、图集、频道等等都是自己自由的,所以如果能在文章页加上文章的评论更是锦上添花,所以很多人也想了很多的办法添加评论功能,有些人也想过使用自定义表单的方法来添加评论,但是这样就会麻烦,现在给大家讲解的就是使用ajax来添加评论功能。
在使用自定义表单提交的基础上修改就可以了,查看一下文章页中的评论提交页,action指向的文件是plus/feedback.php这个文件。
<input type="hidden" name="action" value="send" />
<input type="hidden" name="comtype" value="comments">
<input type="hidden" name="username" value="youke">
<input type="hidden" name="oldurl" value="http://www.521php.com">
<input type="hidden" name="aid" value="179" />
<input type="text" name="msg" value="" />
<input type="hidden" name="isconfirm" value="yes" />
action为操纵类型,send代表发布评论,comtype为comments时表示是评论,这个username和oldurl为我自己定义的变量,是为了填写评论的内容,oldurl为评论发布成功后跳转的页面。
验证码:
<input name="validate" type="text" id="validate" size="10" style="height:18px;width:60px;margin-right:6px;text-transform:uppercase;" class="nb" />
<img src='http://local.de.com/include/vdimgck.php' width='60' height='24' style="cursor:pointer" onclick="this.src=this.src+'?'" title="点击我更换图片" alt="点击我更换图片" />
其中,aid是文章的id,在内容页中可以用{dede:field.id/}获得,在头部调用一个js,{dede:global.cfg_cmsurl/}/,在织梦内容页中加上<dd id=’commetcontent’></dd>这个是放获取的评论内容,添加以下代码到文件的后面:
<script language='javascript'>
function LoadCommets(page)
{
var taget_obj = document.getElementById('commetcontent');
var waithtml = "<div style='line-height:50px'><img src='{dede:global.cfg_cmsurl/}/images/loadinglit.gif' />评论加载中...</div>";
var myajax = new DedeAjax(taget_obj, true, true, '', 'x', waithtml);
myajax.SendGet2("{dede:global.cfg_phpurl /}/feedback_ajax.php?dopost=getlist&aid={dede:field.id/}&page="+page);
DedeXHTTP = null;
}
LoadCommets(1);
</script>
在plus/feedback_ajax.php中的GetList()函数中定义评论列表的样式,调取的内容就可以了。

(责任编辑:最模板)
------分隔线----------------------------
栏目列表
推荐内容