用织梦CMS与DISCUZ同时网站建设时,可以将织梦CMS与DISCUZ进行整理,并且互相调用。织梦CMS假如要调用DISCUZ论坛中的贴子,需要二个程序的网站放在同一个数据库中。
1、织梦CMS调用DISCUZ论坛最新主题代码如下:
{dede:loop table=pre_forum_thread sort=tid row=10}
a href=/bbs/viewthread.php?tid=[field:tid /]
[field:subject function=cn_substr /] /])/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 /] /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 /] /])/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 /] /])/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 /] /])/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 /]/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 /] /a
{ /dede:loop }
注:这种办法这个还有点问题,它会将论坛分区、版块都调出来。望达人改进!
[4] if 查看条件
附:织梦CMS的LOOP 标记规则
功能说明:用于调用任意表的数据,一般用于调用论坛贴子之类的操作
[1] table 表示查看的数据表
[2] sort 用于排序的字段 也可以加views
适用范围:所有模板
基本语法:
{ dede:loop table= sort= row= if= }