【编者按】网学网网络知识频道为大家收集整理了“PHPCMS V9调用Discuz X2.5指定版块帖子“提供大家参考,希望对大家有所帮助!
调用论坛指定版块帖子或回复:
{pc:get sql="SELECT * FROM discuzx.pre_forum_post where first=1 and fid=62 order by tid desc" num="1" cache="" return="data"}
{loop $data $key $val}
<dt><a href="http://论坛网址/thread-{$val[tid]}-1-1.html"><strong> {str_cut($val[subject],60,'''')}</strong></a></dt>
<dd>
<p>{str_cut($val[message],168,'''')}…</p>
</dd>
{/loop}
{/pc}
解释:first=1 就是帖子的1楼,如果=0 就是调用回复。message 截取168字符。fid=62 是论坛版块号
效果如下:
调用论坛最新帖子 并显示版块名称:
{pc:get sql="SELECT a.*,b.* FROM discuzx.pre_forum_thread as a left join discuzx.pre_forum_forum as b on a.fid=b.fid order by tid desc" num="4" cache="" return="data"}
{loop $data $key $val}
<li><a id="lanmu" href="http://论坛网址/forum-{$val[fid]}-1.html">[{$val[name]}]</a>& amp; lt;a href="http://论坛网址/thread-{$val[tid]}-1-1.html"> {str_cut($val[subject],60,'''')}</a></li>
{/loop}
{/pc}
效果:
按积分排行调用论坛用户头像和名称,也可以将 credits改成regdate,就是最新注册加入的会员
{pc:get sql="SELECT * FROM discuzx.pre_common_member order by credits desc" num="10" cache="" return="data"}
{loop $data $key $val}
<span>
<a href="http://论坛网址/space-uid-{$val[uid]}.html"><img alt="{$val[username]}" src="http://论坛网址/uc_server/avatar.php?uid={$val[uid]}&size=small" /></a>
<a href="http://论坛网址/space-uid-{$val[uid]}.html">{str_cut($val[username],9,'''')}</a>
</span>
{/loop}
{/pc}
热门版块排行
{pc:get sql="SELECT * FROM discuzx.pre_forum_forum order by threads desc" num="10" cache="" return="data"}
{loop $data $key $val}
<li><span><a href="http://论坛网址/forum-{$val[fid]}-1.html">{$val[name]}</a>& amp; lt;/span> <span><!--<span class="fatieshu">{$val[threads]}</span>主题 -->共<span class="fatieshu">{$val[posts]}</span>帖 今<span class="fatieshu">{$val[todayposts]}</span>帖</span>< /li>
{/loop}
{/pc}
最热帖
{pc:get sql="SELECT * FROM discuzx.pre_forum_thread order by views desc" num="6" cache="" return="data"}
{loop $data $key $val}
<li><a href="http://论坛网址/thread-{$val[tid]}-1-1.html">{str_cut($val[subject],54,'''')}</a></li>
{/loop}
{/pc}
最新帖
{pc:get sql="SELECT * FROM discuzx.pre_forum_thread order by tid desc" num="6" cache="" return="data"}
{loop $data $key $val}
<li><a href="http://论坛网址/thread-{$val[tid]}-1-1.html">{str_cut($val[subject],54,'''')}</a></li>
{/loop}
{/pc}
原文地址:http://www.liyingqing.com/archives/1238