织梦dedecms如何调用discuz指定版块最新帖子

92建站   织梦CMS   2021-01-15   收藏本文

本文主要介绍了织梦dedecms如何调用discuz指定版块最新帖子,其实还有很多别的功能,推荐给有此需要的朋友,值得仔细研究使用。

第一种方法:

{dede:sql sql="select * from ultrax.pre_forum_ thread where fid=37 limit 0,10"}

<li><a href="/bbs/forum.php?mod=viewthread&tid=[field:tid /] ">

[field:subject function="cn_substr('@me',60)" /] [field:lastpost function="date('m-d H:M','@me')" /] </a></li>

{/dede:sql}

ultrax.pre_forum_ thread为数据库和表名。

Fid是板块的id。

第二种方法:

1. 网上的教程都是针对 Dz7.0, dx1.0 dx1.5 dx2.0 数据表名已 经变化,所以table="cdb_threads"要改成table="pre_forum_thread"。

2. 一般论坛都安装在BBS子目录下,所以引用的地址应改为:

如果是discuz 动态论坛

href="[field:global.cfg_cmspath/]/bbs/viewthread.php? tid=[field:tid /]”

如果是discuz 静态论坛

href="[field:global.cfg_cmspath/]/bbs/thread-[field:tid /]-1-1.html"

说明:[field:global.cfg_cmspath/] 为dede安装目录,你也可以使用绝对路 径,如:

href=你 的网站/bbs/thread-[field:tid /]-1-1.html

1. dede调用 Dx1.0之后,包括 dx1.5, dx2.0 静态论坛最新主题 的方法:(伪静态)

{dede:loop table="pre_forum_thread" if="displayorder!=- 1" sort="tid" row="10"}<a href=" [field:global.cfg_cmspath/]/bbs/thread-[field:tid /]-1- 1.html">•[field:subject function="cn_substr ('@me',30)" /]</a><br/>{/dede:loop}

2、论坛指定版块帖子调用方法: (伪静态)

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

<a href=" [field:global.cfg_cmspath/]/bbs/thread-[field:tid /]-1-1.html" 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=" [field:global.cfg_cmspath/]/bbs/thread-[field:tid /]-1- 1.html">

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

<br/>

{/dede:loop} 

4. 如果想调用某个板块的精华主题 代码如下:(伪静态)

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

<a href=" [field:global.cfg_cmspath/]/bbs/thread-[field:tid /]-1- 1.html">

[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=" [field:global.cfg_cmspath/]/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} 

其中sort="views" 就是控制按照查看 次数排序的代码

5、论坛置顶版块帖子调用方法举 例:(伪静态)

{ dede:loop table=“pre_forum_thread” sort="dateline" if="fid='3' and typeid='51'" row="10" }

<a href=" [field:global.cfg_cmspath/]/bbs/thread-[field:tid /]-1-1.html" target="_blank">

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

{ /dede:loop }

论坛最新主题调用:

{dede:loop table=" pre_forum_thread " sort="tid" 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}

调用特定板块的主题

{dede:loop table=" pre_forum_thread" if="fid=5 and displayorder!=-1" sort="tid" 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 table=" pre_forum_thread " if="fid=5 AND digest>0 and displayorder!=-1 " sort="tid" 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/>

调用论坛指定板块精 华帖(按查看次 数排序):

论坛最新主题: <br/>

{dede:loop table=" pre_forum_thread " if="fid=5 and displayorder!=- 1" 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}

以往的方法都是针对Dz7.0,dx1.0 dx1.5 dx2.0 数据表名已经变化,所以table="cdb_threads"要改成table="pre_forum_thread"。

2. 开启了伪静态论坛与动态论坛引用地址 是不一样的。假设论坛安装在BBS子目录下,那么引用的地址应改为:

discuz静态论坛

href="[field:global.cfg_cmspath/]/bbs/thread-[field:tid /]-1-1.html"

discuz动态论坛

href="[field:global.cfg_cmspath/]/bbs/viewthread.php?tid=[field:tid /]”

说明: [field:global.cfg_cmspath/]为dede安装目录,你也可以使用绝对路径,如:

href=http://www.dede58.com/bbs/thread-[field:tid /]-1 -1.html

href=http://www.dede58.com/thread-[field:tid /]-1- 1.html  (开启bbs为子域名)

结合网上关于dede调用dz7.0以前的教程,得出dede调用 dx静态论坛最新方法:

1. dede调用  Dx1.0之后,包括dx1.5,dx2.0 静态论坛最新主题的方法 :(伪静态)

{dede:loop table="pre_forum_thread" sort="tid" row="10"}<a href=" [field:global.cfg_cmspath/]/bbs/thread-[field:tid /]-1- 1.html">•[field:subject function="cn_substr ('@me',30)" /]</a><br/>{/dede:loop}

2. 我调用的是最新发布的帖子。调用代码如下:

<UL>

{dede:loop table='**********.pre_forum_thread' sort='tid' row='16' }

<LI><A href="/shequ/forum.php? mod=viewthread&tid=[field:tid /]"  target=_blank> [field:subject function='cn_substr(@me,32)'/]</A> </LI>

{/dede:loop}

</UL>

说明:**********.pre_forum_thread 其中的**********是你的数据库名称 ,另外还要把代码中的shequ修改为你的 discuz x的安装目录名称。你的DZX目录是什么就写什么,这 点很重要!如果你是调用的静态的,那么就把代码中的链接改为的格式就可以了。 根据你的网站需要你还可以修改其中的调用条数row='16'

上面是动态内容的调用,如果你的论坛做了伪静态处 理,那么调用的链接、修改下就可以了!调用演示如下:

<UL>

{dede:loop table='**********.pre_forum_thread' sort='tid' row='16' }

<LI><A href="/shequ/thread-[field:tid /]-1- 1.html" >[field:subject function='cn_substr(@me,32)'/] </A> </LI>

{/dede:loop}

</UL>

如果调用的需要新窗口打开的话,可以在 shequ/thread-[field:tid /]-1- 1.html后面加上target="_blank" 例如:

<UL>

{dede:loop table='**********.pre_forum_thread' sort='tid' row='16' }

<LI><A href="/shequ/thread-[field:tid /]-1- 1.html"  target=_blank>[field:subject function='cn_substr (@me,32)'/]</A> </LI>

{/dede:loop}

</UL>

最后,下面发一个DEDE调用 discuz x的家园home.php最新日志的代码调用代码如下(动态调用演 示):

{dede:loop table='你的数据库名.pre_home_blog' sort='blogid' row='12'}

<LI>·<A href="/你的DZ X安装子目录名/home.php?mod=space&uid=[field:uid/]&do=blog&id= [field:blogid/]" 

target=_blank>[field:subject function='cn_substr(@me,28)'/] </A> </LI>

{/dede:loop}

同样你要修改你的数据库名,或你安装DZX的目录名,其实都很简单 ,以前DEDE调用DZ的时候数据表名不一样,论 坛的cdb_threads数据表名变成了现在的pre_forum_thread UCHOME的uchome_blog变成了现在的pre_home_blog。

上面就是织梦调用DZ帖子的介绍,若有疑问可以找小编进一步探讨交流~

TAG标签: 织梦调用DZ帖子
旺铺招租1 旺铺招租2 旺铺招租3 旺铺招租4 旺铺招租5 旺铺招租6
展开