Discuz论坛在首页或者帖子内页调用帖子列表,并没有现成的代码来调用。需要使用PHP代码自己对数据库进行操作。通过调用数据库可以实现在论坛任意位置调用帖子列表。
下面是Discuz论坛首页/内页调用帖子列表的代码。 一、DISCUZ调用论坛里所有版块的帖子列表: [HTML] 纯文本查看 复制代码 <!--{eval $slides = DB::fetch_all("SELECT * FROM ".DB::table('forum_thread')." ORDER BY `dateline` DESC LIMIT 0, 6");}-->
<ul>
<!--{loop $slides $slide}-->
<li>
<a href="forum.php?mod=viewthread&tid=$slide[tid]" title="$slide[subject]" target="_blank" >
<p><img src="uc_server/avatar.php?uid=$slide['authorid']&size=small"></p>
<p>$slide[subject</p>
<p>日期<!--{echo date("m-d",$slide[dateline)}--> 浏览( $slide[views ) 评论( $slide[replies )</p>
</a>
</li>
<!--{/loop}-->
</ul>
二、DISCUZ调用论坛里指定版块ID的帖子列表:(tid='1') [HTML] 纯文本查看 复制代码 <!--{eval $slides = DB::fetch_all("SELECT * FROM ".DB::table('forum_thread')." WHERE tid='1' ORDER BY `dateline` DESC LIMIT 0, 6");}-->
<ul>
<!--{loop $slides $slide}-->
<li>
<a href="forum.php?mod=viewthread&tid=$slide[tid]" title="$slide[subject]" target="_blank" >
<p><img src="uc_server/avatar.php?uid=$slide['authorid']&size=small"></p>
<p>$slide[subject</p>
<p>日期<!--{echo date("m-d",$slide[dateline)}--> 浏览( $slide[views ) 评论( $slide[replies )</p>
</a>
</li>
<!--{/loop}-->
</ul>
三、DISCUZ调用论坛帖子当前版块的帖子列表:(tid=".$slide[tid].") [HTML] 纯文本查看 复制代码 <!--{eval $slides = DB::fetch_all("SELECT * FROM ".DB::table('forum_thread')." WHERE tid=".$slide[tid." ORDER BY `dateline` DESC LIMIT 0, 6");}-->
<ul>
<!--{loop $slides $slide}-->
<li>
<a href="forum.php?mod=viewthread&tid=$slide[tid]" title="$slide[subject]" target="_blank" >
<p><img src="uc_server/avatar.php?uid=$slide['authorid']&size=small"></p>
<p>$slide[subject</p>
<p>日期<!--{echo date("m-d",$slide[dateline)}--> 浏览( $slide[views ) 评论( $slide[replies )</p>
</a>
</li>
<!--{/loop}-->
</ul>
四:DISCUZ调用帖子列表并且带图片 [HTML] 纯文本查看 复制代码 <div class="theportal_xihuan_list">
<ul>
<!--{eval $slides = DB::fetch_all("SELECT * FROM ".DB::table('forum_thread')." ORDER BY `dateline` DESC LIMIT 0, 28");}-->
<!--{loop $slides $slide}-->
<li>
<!--{eval $tupian = DB::result(DB::query("SELECT attachment FROM ".DB::table('forum_threadimage')." WHERE tid = '$slide[tid]' "));}-->
<div>
<a class="pic" href="forum.php?mod=viewthread&tid=$slide[tid]" target="_blank"> <img src="data/attachment/forum/$tupian" alt="$slide[subject]" title="$slide[subject]"></a>
<div class="details">
<h3><a href="forum.php?mod=viewthread&tid=$slide[tid]" target="_blank">$slide[subject</a></h3>
<div class="row">作者:$slide[author | 最后更新:<!--{echo date("Y-m-d",$slide[dateline)}--></div>
</div>
</div>
</li>
<!--{/loop}-->
</ul>
</div>
|