DEDECMS调用DISCUZ论坛置顶贴子,版块名称


使用织梦DEDECMS与DISCUZ同时建站时,可以将DEDECMS与DISCUZ进行整合,并且互相调用。DEDECMS如果要调用DISCUZ论坛中的贴子,必须二个程序的网站放在同一个数据库中。

1、DEDECMS调用DISCUZ论坛最新主题代码如下:

{dede:loop table=”pre_forum_thread” sort=”tid” row=”10″}

<a href=”/bbs/viewthread.php?tid=[field:tid /]”>

·[field:subject function=”cn_substr(‘@me’,30)” /]([field:lastpost function=”date(‘m-d H:M’,’@me’)” /])</a>

<br/>

{/dede:loop}

这个连接地址你能够写相对路径,也能够写绝对路径。

假如是discuz动态论坛,链接地址如http://bbs.xxx.com/viewthread.php?tid=[field:tid /]

假如是discuz静态论坛,连接地址如http://bbs.xxx.com/thread-[field:tid /]-1-1.html

{ dede:loop table=”pre_forum_thread” if=”fid=1 or fid=2 and displayorder!=-1″ sort=”tid” row=”6″ }

<a href=”/bbs/viewthread dot php?tid=[field:tid /]” target=”_blank”>

·[field:subject function=”cn_substr(‘ @ me’,50)” /] </a>

<br/>

{ /dede:loop }

其中的fid=1 or fid=2是论坛主题分类id,能够按照自己要求来修改,假如是一个分类就直接写fid=x

3、论坛调精华主题调用代码如下:

{dede:loop table=”pre_forum_thread” if=”displayorder!=-1″ sort=”tid” row=”10″}

<a href=”/bbs/viewthread.php?tid=[field:tid /]”>

·[field:subject function=”cn_substr(‘@me’,30)” /]([field:lastpost function=”date(‘m-d H:M’,’@me’)” /])</a>

<br/>

{/dede:loop}

假如想调用某个板块的精华主题代码如下:

{dede:loop table=”pre_forum_thread” if=”fid=5 and displayorder!=-1″ sort=”tid” row=”10″}

<a href=”/bbs/viewthread.php?tid=[field:tid /]”>

·[field:subject function=”cn_substr(‘@me’,30)” /]([field:lastpost function=”date(‘m-d H:M’,’@me’)” /])</a>

<br/>

{/dede:loop}

其中的fid=5是论坛主题分类id,能够按照自己要求来修改,

假如想调用论坛所有的板块的最新精华主题只要去掉fid=5 and 就能够了。

4、调用的帖子列表这能够按查看次数排序,代码如下:

{dede:loop table=”pre_forum_thread” sort=”views” row=”10″}

<a href=”/dz/viewthread.php?tid=[field:tid /]”>

·[field:subject function=”cn_substr(‘@me’,30)” /]([field:lastpost function=”date(‘m-d H:M’,’@me’)” /])</a>

<br/>

{/dede:loop}

其中sort=”views” 就是操纵 按照查看次数排序的代码

5、论坛置顶版块帖子调用方法举例:

{ dede:loop table=”pre_forum_thread” sort=”dateline” if=”fid=’3′ and typeid=’51′” row=”10″ }

<a href=”/a/bbs/viewthread dot php?tid=[field:tid /]” target=”_blank”>

·[field:subject function=”cn_substr(‘ @ me’,30)” /]</a> <br>

{ /dede:loop }

6、论坛版块名称调用方法:

{ dede:loop table=”cdb_forums” sort=”displayorder” row=”16″ col=”4″ }

<a href=”/bbs/viewthread dot php?fid=[field:fid /]”>·[field:name function=”cn_substr(‘ @me’,30)” /] </a>

{ /dede:loop }

注:这种方法这个还有点问题,它会将论坛分区、版块都调出来。望达人改进!

附:dedecms的LOOP 标记规则

功能说明:用于调用任意表的数据,通常用于调用论坛贴子之类的操作

适用范围:所有模板

基本语法:

{ dede:loop table=’ sort=” row=” if=” }

[1] table 表示查询的数据表

[2] sort 用于排序的字段 也能够加”views”(查看次数排列)

[3] row 返回结果的条数

[4] if 查询条件