使用thinkPHP框架怎么实现一个无限回复评论功能
作者
这篇文章将为大家详细讲解有关使用thinkPHP框架怎么实现一个无限回复评论功能,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
control控制器部分:
functionCommentList($pid=0,&$commentList=array(),$spac=0){
static$i=0;
$spac=$spac+1;//初始为1级评论
$List=M('comment')->
field('id,add_time,author,content,pid')->
where(array('pid'=>$pid))->order("idDESC")->select();
foreach($Listas$k=>$v){
$commentList[$i]['level']=$spac;//评论层级
$commentList[$i]['author']=$v['author'];
$commentList[$i]['id']=$v['id'];
$commentList[$i]['pid']=$v['pid'];//此条评论的父id
$commentList[$i]['content']=$v['content'];
$commentList[$i]['time']=$v['add_time'];
//$commentList[$i]['pauthor']=$pautor;
$i++;
$this->CommentList($v['id'],$commentList,$spac);
}
return$commentList;
}view视图部分:
<volistname="commentList"id="vo">
<eqname="vo.pid"value="0"><hrclass="solidline"/><else/><hrclass="dottedline"/></eq>
<divclass="commentList">
<div><spanclass="user">
<ifcondition="($vo.pauthoreqNULL)">{$vo.author}
<else/>{$vo.author}<spanclass="black">回复</span>{$vo.pauthor}
</if>
</span><aclass="hf"id="{$vo.id}">回复</a><spanclass="hftime">{$vo.time|date="Y-m-d",###}</span></div>
<divclass="content">{$vo.content|reFace}</div>
</div>
</volist>关于使用thinkPHP框架怎么实现一个无限回复评论功能就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
目录
推荐阅读
-
如何快速解决ThinkPHP5.1出现MISS缓存未命中问题
如何快速解决ThinkPHP5.1出现MISS缓存未命中问题这篇文...
-
thinkphp 6.0 swoole扩展websocket使用教程
-
PHP之ThinkPHP框架,让你10分钟快速入门,还免费包教会哟
-
ThinkPHP5.0目录结构,作用及其初略说明
-
Thinkphp在IIS7.5里的伪静态代码,亲测,收藏
-
哪些PHP开源作品值得关注
-
开源学校教务管理系统
-
一次项目中Thinkphp绕过禁用函数的实战记录
-
thinkphp如何用中间件记录行为日志
-
thinkphp3.1与3.2的区别有哪些
thinkphp3.1与3.2的区别有哪些今天小编给大家分享一下t...
