最近帮朋友整合了DEDECSM V5.6和discuz x1.5后,朋友又再次找到我,咨询如何实现在织梦CMS的相关栏目中调用论坛的相关数据。于是我尝试调用“活跃会员”“指定帖子”“帖子中的图片”这三个内容,经过一天的努力,终于实现,现在发出来,提供给大家研究学习。
一、调用活跃会员:
{dede:loop table="pre_common_member" sort="credits" row="5" infolen='4'}
<tr>
<td><div style="margin-top:5px;"><A href="/bbs/home.php?mod=space&uid=[field:uid /]" target="_blank"><IMG src="/bbs/uc_server/avatar.php?uid=[field:uid /]&size=middle" width="35" height="26"></A><A href="/bbs/home.php?mod=space&uid=[field:uid /]" target="_blank" style="font-size:12px; color:#626262; margin-left:5px;">[field:username/]</A></div></td>
</tr>{/dede:loop}
二、调用指定板块帖子
{dede:loop table="pre_forum_thread" if="fid=42" sort="tid" row="4"}
<li class="li3 font-size text2">
<A href="/bbs/forum.php?mod=viewthread&tid=[field:tid /]&extra=page%3D1" target="_blank" style="color:#626262">·[field:subject function="cn_substr('@me',30)" /]</A> </li> {/dede:loop}
三、调用帖子中的图片
{dede:sql sql="SELECT`pre_forum_attachment`.`aid`, `pre_forum_attachment`.`attachment`,`pre_forum_thread`.`tid`, `pre_forum_thread`.`fid`, `pre_forum_thread`.`subject` FROM `pre_forum_attachment` LEFT JOIN `pre_forum_thread` ON `pre_forum_thread`.`tid`=`pre_forum_attachment`.`tid` WHERE `pre_forum_attachment`.`readperm`='0' AND `displayorder`>='0' AND `filetype`='application/octet-stream' GROUP BY tid LIMIT 1,5 "}
<div class="floatl margint content-bottom1">
<div class="floatl">
<a href="/bbs/forum.php?mod=viewthread&tid=[field:tid /]">
<img src="/bbs/data/attachment/forum/[field:attachment/]" ALT="[field:subject/]" width="100" height="80" border="0" /> </a>
</div>
<div class="floatl margint font-size" style="*margin-top:0;">
<a href="/bbs/forum.php?mod=viewthread&tid=[field:tid /]">[field:subject function="cn_substr('@me',18)"/]</a>
</div>
</div> {/dede:sql}
最终效果如下图:
|