亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

thinkPHP框架實(shí)現(xiàn)的無限回復(fù)評(píng)論功能示例

 更新時(shí)間:2018年06月09日 09:10:37   作者:徐彬  
這篇文章主要介紹了thinkPHP框架實(shí)現(xiàn)的無限回復(fù)評(píng)論功能,結(jié)合實(shí)例形式簡單分析了thinkPHP實(shí)現(xiàn)無限回復(fù)的相關(guān)控制器、視圖操作技巧,需要的朋友可以參考下

本文實(shí)例講述了thinkPHP框架實(shí)現(xiàn)的無限回復(fù)評(píng)論功能。分享給大家供大家參考,具體如下:

如果只是簡單的單回復(fù)的評(píng)論的話,那樣操作是很簡單的。但問題就是如何實(shí)現(xiàn)無限的回復(fù)評(píng)論呢!那么如果只是單回復(fù)的話,需要建好多的數(shù)據(jù)表,是根本不可能實(shí)現(xiàn)的。那么用TP框架實(shí)現(xiàn)無限回復(fù)評(píng)論(GitHub源代碼下載地址:https://github.com/Jonybin/responsemessage)下載完成后,注意數(shù)據(jù)庫的使用。

control控制器部分:

function CommentList($pid = 0, &$commentList = array(), $spac = 0) {
    static $i = 0;
    $spac = $spac + 1; //初始為1級(jí)評(píng)論
    $List = M('comment')->
        field('id,add_time,author,content,pid')->
        where(array('pid' => $pid))->order("id DESC")->select();
    foreach ($List as $k => $v) {
      $commentList[$i]['level'] = $spac; //評(píng)論層級(jí)
      $commentList[$i]['author'] = $v['author'];
      $commentList[$i]['id'] = $v['id'];
      $commentList[$i]['pid'] = $v['pid']; //此條評(píng)論的父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視圖部分:

<volist name="commentList" id="vo">
 <eq name="vo.pid" value="0"><hr class="solidline"/><else/><hr class="dottedline"/></eq>
 <div class="commentList " style="padding-left:{$vo['level']-1}cm">
   <div><span class="user">
   <if condition="($vo.pauthor eq NULL)">{$vo.author}
  <else /> {$vo.author}<span class="black" style="color: #000101">回復(fù)</span>{$vo.pauthor}
   </if>
 </span><a class="hf" id="{$vo.id}" style="float: right">回復(fù)</a><span class="hftime">{$vo.time|date="Y-m-d",###}</span></div>
   <div class="content">{$vo.content|reFace}</div>
 </div>
</volist>

完整實(shí)例代碼可點(diǎn)擊此處本站下載。

更多關(guān)于thinkPHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《ThinkPHP入門教程》、《thinkPHP模板操作技巧總結(jié)》、《ThinkPHP常用方法總結(jié)》、《codeigniter入門教程》、《CI(CodeIgniter)框架進(jìn)階教程》、《Zend FrameWork框架入門教程》及《PHP模板技術(shù)總結(jié)》。

希望本文所述對(duì)大家基于ThinkPHP框架的PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論