Dedecms(织梦)调用discuz X2论坛(指定板块)最新帖子的方法
第一种方法:
{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:sub
ject 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=www.hudongs/bbs/thread-[field:tid /]-1-1.html
? ?? ?? ?? ?? ?? ?? ? href=bbs.hudongs/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}
我调用的是最新发布的discuz还有人用吗
帖子。调用代码如下:
 <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。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。