在我们使用织梦CMS的时候可能会用到要随机调佣栏目,那么织梦CMS是如何随机调用栏目的呢?代码如下:
{dede:sql sql="SELECT * FROM `dede_arctype` AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM `dede_arctype`)-(SELECT MIN(id) FROM `dede_arctype`))+(SELECT MIN(id) FROM `dede_arctype`)) AS id) AS t2 WHERE t1.id >= t2.id ORDER BY t1.id LIMIT 1"} <a href='[field:typeurl/]'><span>[field:typename/]</span></a><br> {/dede:sql}
最后limit 1 改成多条调用
[field:typedir function='str_replace("{cmspath}","",@me)'/]
PS:由于随机调用栏目非常占用CPU,CMS建站教程不建议大家使用
评论前必须登录!
注册