jekeyhui99 发表于 2015-10-30 18:19:31

DedeCMS非JS方法调用Discuz论坛数据(含非同一数据库下)

最近在整合dedecms5.6和discuz! x1.5,希望能通过dede首页来调用discuz的相关帖子数据,由于discuzx 后台-门户-模块管理-数据调用 只能以JS方式远程调用论坛的数据,这里说说用DEDE的标记语言直接从数据库调用,这样的优点就是方便蜘蛛的抓取,但同时也会加重服务器的负担。一、DEDECMS官方的调用动态地址代码:论坛新帖子:
<br/>
{dede:loop table="pre_forum_thread " sort="tid" row="10"}
    <a href="http://bbs.xx.com/viewthread.php?tid=">
       ()
   </a>
<br/>
{/dede:loop}其中的 http://bbs.xx.com/ 是论坛的地址;pre_forum_thread 数据库的表名;('@me',30)调用标题的字符数30,相当于15个汉字;()标题后调用发帖的时间,可按需要调用。二、调用Discuz论坛伪静态地址代码,dedecms数据库和discuzx数据库不在同一库内。{dede:loop table="discuzbbs.pre_forum_thread " sort="tid" row="10"}
    <a href="http://bbs.xx.com/thread--1-1.html" target="_blank">
      
    </a>
{/dede:loop}说明:discuzbbs.pre_forum_thread,其中红色的“discuzbbs”是discuz论坛的数据库名,pre_forum_thread是帖子表名,pre_替换为你的具体的表前缀。由此,也能看出DedeCMS的数据库和discuz的数据库不在同一个库内。注:非同一库内的数据调用格式:discuz论坛数据库名.   ps.记得后面的点。蓝色字体就是你的论坛地址   过这这能调用第一页的内容 thread--1-*.html *代表页数三、DEDECMS调用指定分类文章demo1:
{dede:loop table="discuzbbs.pre_forum_thread " if="fid=6 and displayorder!=-1" sort="tid" row="10" }
    <a href="http://bbs.xx.com/thread--1-1.html" target="_blank"></a>
   
{/dede:loop}demo2:
{dede:loop table="discuzbbs.pre_forum_thread " if="fid=1||fid=2 and displayorder!=-1" sort="tid" row="6"}
    <a href="http://bbs.xx.com/viewthread.php?tid=" target="_blank">
      
    </a>
{/dede:loop}说明: 调用作者和文章时间fid=6 是discuz栏目的ID

页: [1]
查看完整版本: DedeCMS非JS方法调用Discuz论坛数据(含非同一数据库下)