Discuz7.0实现树形浏览回复的效果

这两天都在赶项目,累。

有一个Discuz+DEDE整合的网站项目,需要实现下面的效果,今天晚上粗略看了一下,写了一个无限级获取回复下的回复。

tree

以下是实现的效果,等美工把CSS写出来,就可以看到效果了。

mytree

以下是核心函数,有需要者拿走,因为我看到好多朋友都需要这样的功能。

[php]function GetRepPost($pid,$tid,$first=”){
global $db;
if($first){
$pid = "0,$tid,$pid";
}

$total = $db->fetch_first("SELECT count(*) as total FROM `cdb_posts` where tid = ‘$tid’ and reppost in($pid) order by pid;");
if(!$total[‘total’]) return;

$query = $db->query("SELECT * FROM `cdb_posts` where tid = ‘$tid’ and reppost in($pid) order by pid;");
$replay .= "<ul>\r\n";
while($re = $db->fetch_array($query)){
$pid = $re[‘pid’];
$subject[] = $re[‘subject’];
$count .="\t";
!$re[‘subject’] && $re[‘subject’] = "RE:{$subject[0]}";
$replay .= "{$count}<li>{$pid}->{$re[‘subject’]}</li>\r\n";
$replay .= GetRepPost($pid,$tid);
}
$replay .= "</ul>\r\n";
return $replay;
}[/php]

接下来的开发中,对加上对回复的帖子进行短信通知,过期检测,列表显示和浏览切换。

发表评论