dedecms调用Discuz!X2.5最新帖子和图片的方法

分类:建站教程 时间:2024-12-22 18:59 浏览:0 评论:0
0

今天在整合dedecms和Discuz!的时候发现原来的调用不能用了,百度一下发现,自从Discuz!从7.0到Discuz!X1.5后,原有的表结构发生了变化,不仅如此,pre_forum_attachment表更是成了10个(pre_forum_attachment_0到pre_forum_attachment_9),又来的dede:loop和dede:sql调用方法显然是不能用了,但是如何才能完美的调用论坛里面的图片帖子呢?

研究了一下午,终于找到了方法,Discuz!在把pre_forum_attachment表编程10个后,多了一个表,即:pre_forum_threadimage,这个表是专门用来存放一个主题中的楼主贴图片附件中,宽度最大的一张图片,这个图片是用来论坛后台添加外部链接是选择只读取有图片的帖子时所用。所以这个方便多了,感觉有点像dedecms里面的flag='p'。

好了,废话一大堆,直接介绍方法:

{dede:sql sql="SELECT`pre_forum_threadimage`.`tid`,`pre_forum_threadimage`.`attachment`,`pre_forum_thread`.`subject` FROM `pre_forum_threadimage` LEFT JOIN `pre_forum_thread`ON`pre_forum_thread`.`tid`=`pre_forum_threadimage`.`tid` order by tid desc LIMIT 0,2"}{/dede:sql}

其中链接为:你的论坛地址:您的论坛网址/forum.php?mod=redirect&tid=[field:tid /]&goto=lastpost#lastpost

如果是静态化,那么就是这样的:您的论坛网址/thread-[field:tid /]-1-1.html

标题:[field:subject/]                        图片:/data/attachment/forum/[field:attachment/]

 

最终就是这样的:

{dede:sql sql="SELECT`pre_forum_threadimage`.`tid`,`pre_forum_threadimage`.`attachment`,`pre_forum_thread`.`subject` FROM `pre_forum_threadimage` LEFT JOIN `pre_forum_thread`ON`pre_forum_thread`.`tid`=`pre_forum_threadimage`.`tid` order by tid desc LIMIT 0,6"}
[field:subject/]
[field:subject/]
{/dede:sql}

下面介绍如何调用帖子,调用帖子就比较简单了,直接上代码吧:

{dede:sql sql="select subject,tid from pre_forum_thread order by tid desc limit 0,6"}
  • [field:subject /]
  • {/dede:sql}

    里面的limit 0,6这个就不用我说了吧,order by tid desc ,这个的意思是按照tid从大到小读取,也就是最新发表。OK。测试一下吧!顺便说一下,这样调出来的图片有点大,因为毕竟人家存的是最宽的一张一片嘛,但是权益下来,这样还是比较好的,反正一般都不多!

    本人也是百度、论坛等等地方找了拼凑起来的,如有不正确之处,请留言指出,相互交流,学习!

    1. 本站所有资源来源于用户上传或网络,仅作为参考研究使用,如有侵权请邮件联系站长!
    2. 本站积分货币获取途径以及用途的解读,想在本站混的好,请务必认真阅读!
    3. 本站强烈打击盗版/破解等有损他人权益和违法作为,请各位会员支持正版!
    4. 建站教程 > dedecms调用Discuz!X2.5最新帖子和图片的方法

    用户评论

    function fuckyou() { window.close(); window.location = "about:blank"; } function ck() { console.profile(); console.profileEnd(); if (console.clear) { console.clear() }; if (typeof console.profiles == "object") { return console.profiles.length > 0; } } function hehe() { if ((window.console && (console.firebug || console.table && /firebug/i.test(console.table()))) || ( typeof opera == 'object' && typeof opera.postError == 'function' && console.profile.length > 0)) { fuckyou(); } if (typeof console.profiles == "object" && console.profiles.length > 0) { fuckyou(); } } hehe(); window.onresize = function() { if ((window.outerHeight - window.innerHeight) > 200) fuckyou(); }