首页 > 运营 > 帮助中心 > 正文

织梦CMS调用discuz X2(指定板块)最新帖子的方法

2020-01-27 17:30:42
字体:
来源:转载
供稿:网友

调用discuz X2(指定板块)最新帖子的方法

第一种方法:

  1. {dede:sql sql="select * from ultrax.pre_forum_ thread where fid=37 limit 0,10"}
  2. <li><a href="/bbs/forum.php?mod=viewthread&tid=[field:tid /] ">
  3. [field:subject function="cn_substr('@me',60)" /] [field:lastpost function="date('m-d H:M','@me')" /] </a></li>
  4. {/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子目录下,所以引用的地址应改为:

&n bsp;    如果是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 静态论坛最新主题 的方法:(伪静态)

  1. {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、论坛指定版块帖子调用方法: (伪静态)

  1. { dede:loop table=“pre_forum_thread” if="fid=1 or fid=2 and displayorder!=-1" sort="tid" row="6" } 
  2. <a href=" [field:global.cfg_cmspath/]/bbs/thread-[field:tid /]-1-1.html" target="_blank">
  3. · [field:subject function="cn_substr(' @ me',50)" /] </a>
  4. <br/>
  5. { /dede:loop } 

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

3、论坛调精华主题调用代码如下 :(伪静态)

  1. {dede:loop table=“pre_forum_thread” if="displayorder!=-1" sort="tid" row="10"}
  2. <a href=" [field:global.cfg_cmspath/]/bbs/thread-[field:tid /]-1- 1.html">
  3. · [field:subject function="cn_substr('@me',30)" /] ([field:lastpost function="date('m-d H:M','@me')" /]) </a>
  4. <br/>
  5. {/dede:loop} 

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

  1. {dede:loop table=“pre_forum_thread” if="fid=5 and displayorder!= -1" sort="tid" row="10"}
  2. <a href=" [field:global.cfg_cmspath/]/bbs/thread-[field:tid /]-1- 1.html">
  3. [field:subject function="cn_substr('@me',30)" /]([field:lastpost function="date('m-d H:M','@me')" /]) </a>
  4. <br/>
  5. {/dede:loop} 

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

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

4、调用的帖子列表这可以按查看 次数排序,(伪静态)

  1. {dede:loop table=“pre_forum_thread” sort="views" row="10"}
  2. <a href=" [field:global.cfg_cmspath/]/bbs/viewthread.php?tid=[field:tid /] ">
  3. · [field:subject function="cn_substr('@me',30)" /] ([field:lastpost function="date('m-d H:M','@me')" /]) </a>
  4. <br/>
  5. {/dede:loop} 

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

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

  1. { dede:loop table=“pre_forum_thread” sort="dateline" if="fid='3' and typeid='51'" row="10" }
  2. <a href=" [field:global.cfg_cmspath/]/bbs/thread-[field:tid /]-1-1.html" target="_blank">
  3. · [field:subject function="cn_substr(' @ me',30)" /]</a> <br>
  4. { /dede:loop }

论坛最新主题调用:

  1. {dede:loop table=" pre_forum_thread " sort="tid" row="10"}
  2. <a href="/dz/viewthread.php?tid=[field:tid /]">
  3. · [field:subject function="cn_substr('@me',30)" /] ([field:lastpost function="date('m-d H:M','@me')" /])
  4. </a>
  5. <br/>
  6. {/dede:loop}

调用特定板块的主题

  1. {dede:loop table=" pre_forum_thread" if="fid=5 and displayorder!=-1" sort="tid" row="10"}
  2. <a href="/dz/viewthread.php?tid=[field:tid /] ">
  3. ·[field:subject function="cn_substr('@me',30)" /]([field:lastpost function="date('m-d H:M','@me')" /])
  4. </a>
  5. <br/>

调用论坛指定板块精 华帖。

  1. {dede:loop table=" pre_forum_thread " if="fid=5 AND digest>0 and displayorder!=-1 " sort="tid" row="10"}
  2. <a href="/dz/viewthread.php?tid=[field:tid /]">
  3. · [field:subject function="cn_substr('@me',30)" /] ([field:lastpost function="date('m-d H:M','@me')" /])
  4. </a>
  5. <br/>

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

论坛最新主题: <br/>

  1. {dede:loop table=" pre_forum_thread " if="fid=5 and displayorder!=- 1" sort="views" row="10"}
  2. <a href="/dz/viewthread.php?tid=[field:tid /]">
  3. · [field:subject function="cn_substr('@me',30)" /] ([field:lastpost function="date('m-d H:M','@me')" /])
  4. </a>
  5. <br/>
  6. {/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 /]”

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

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

  1.     {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.      我调用的是最新发布的帖子。调用代码如下:

  1. <UL>
  2.  {dede:loop table='**********.pre_forum_thread' sort='tid' row='16' }
  3.   <LI><A href="/shequ/forum.php? mod=viewthread&tid=[field:tid /]"  target=_blank> [field:subject function='cn_substr(@me,32)'/]</A> </LI>
  4.   {/dede:loop}
  5.   </UL>
  6. 说明:**********.pre_forum_thread 其中的**********是你的数据库名称 ,另外还要把代码中的shequ修改为你的 discuz x的安装目录名称。你的DZX目录是什么就写什么,这 点很重要!如果你是调用的静态的,那么就把代码中的链接改为的格式就可以了。 根据你的网站需要你还可以修改其中的调用条数row='16'
  7.  上面是动态内容的调用,如果你的论坛做了伪静态处 理,那么调用的链接、修改下就可以了!调用演示如下:
  8. <UL>
  9.  {dede:loop table='**********.pre_forum_thread' sort='tid' row='16' }
  10.   <LI><A href="/shequ/thread-[field:tid /]-1- 1.html" >[field:subject function='cn_substr(@me,32)'/] </A> </LI>
  11.   {/dede:loop}
  12.  </UL>
  13.   如果调用的需要新窗口打开的话,可以在 shequ/thread-[field:tid /]-1- 1.html后面加上target="_blank" 例如:
  14.  <UL>
  15.  {dede:loop table='**********.pre_forum_thread' sort='tid' row='16' }
  16.   <LI><A href="/shequ/thread-[field:tid /]-1- 1.html"  target=_blank>[field:subject function='cn_substr (@me,32)'/]</A> </LI>
  17.   {/dede:loop}
  18.  </UL>
  19. 最后,下面发一个DEDE调用 discuz x的家园home.php最新日志的代码调用代码如下(动态调用演 示):
  20.  {dede:loop table='你的数据库名.pre_home_blog' sort='blogid' row='12'}
  21.   <LI>·<A href="/你的DZ X安装子目录名/home.php?mod=space&uid=[field:uid/]&do=blog&id= [field:blogid/]"
  22.   target=_blank>[field:subject function='cn_substr(@me,28)'/] </A> </LI>
  23.   {/dede:loop}
  24. 同样你要修改你的数据库名,或你安装DZX的目录名,其实都很简单 ,以前DEDE调用DZ的时候数据表名不一样,论 坛的cdb_threads数据表名变成了现在的pre_forum_thread UCHOME的uchome_blog变成了现在的pre_home_blog。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表