需要做一个帝国调用discuz帖子的东西,想到了万能的灵动标签,以前一直知道有这么个东西,但一直没有用过,正好试试效果,研究一番发现还挺简单的:
[e:loop={栏目ID/专题ID,显示条数,操作类型,只显示有标题图片}]
模板内容
[/e:loop]
这里由于要调用非帝国栏目的内容,所以用sql语句来实现,操作类型就是24,截取字数也很简单,因为在灵动标签下市可以直接使用php函数的,所有可以用substr之类的函数,下面是最终的代码:
[e:loop={"select subject as title,author as username,authorid as userid,tid as id from cdb_threads where dateline>UNIX_TIMESTAMP(NOW())-604800 order by views desc limit 8",8,24,0}]
<li>·<a href=”http://bbs.xxx.com/thread-<?=$bqr[id]?>-1-1.html” target=”_blank”><?=esub($bqr[title],30)?>
</a><span><a href=”http://space.xxx.com/space.php?uid=<?=$bqr[userid]?>”><?=esub($bqr[username],8)?></a></span></li>
[/e:loop]
