discuz x3.2调用版主推荐主题
类别:建站知识   时间:10-12

模板中使用:

<!--{eval $fids = '2,36,37,39';$recs=array();$query=DB::query("SELECT * FROM ".DB::table('forum_forumrecommend')." where fid in ($fids) order by `tid` desc limit 10");while($item=DB::fetch($query))$recs[]=$item;}--><!--{loop $recs $rec}--><li><a href="forum.php?mod=viewthread&tid=$rec['tid']">$rec['subject']</a><span class="pipe">|</span>作者<!--{$rec['author']}--></li><!--{/loop}-->
调用来自版块2,36,37,39的推荐主题,按帖子tid倒序排列,取10篇。根据我的想法,想要每个版块只取1篇,总10篇。
那么代码:<!--{eval $fids = '2,36,37,39';$recs=array();$query=DB::query("SELECT fid,max(tid) as tid,subject,tid,author  FROM ".DB::table('forum_forumrecommend')." where fid in ($fids) group by `fid` order by `tid` desc limit 10");while($item=DB::fetch($query))$recs[]=$item;}--><!--{loop $recs $rec}--><li><a href="forum.php?mod=viewthread&tid=$rec['tid']">$rec['subject']</a><span class="pipe">|</span>作者<!--{$rec['author']}--></li><!--{/loop}-->
但是有个比较挫的问题,取一篇的时候,只能取最先推荐的。

智慧半岛,是一家专注于青岛网站建设青岛网站开发的青岛网络公司,Copyright ©2007-2019 Ebandao.Cn 版权所有 All Rights Reserved.(建议在1366x768以上的浏览器中访问)鲁ICP备08014496号

13153297890