欢迎来到元素模板ys720.com,本站提供专业的织梦模板帝国模板网站模板网站修改/网站仿站
当前位置:主页 > 程序教程 > 帝国cms教程 >
帝国cms教程

帝国cms使用灵动标签同时调用新闻和文章等多个表的头条等内容

(元素模板) / 2021-06-21 11:35

灵动标签同时调用多个表的最新内容,多个表用“union”连接:

[e:loop={'select * from (
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_movie where newstime union
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_news where newstime union
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_photo where newstime union
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_flash where newstime union
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_article where newstime
) a order by newstime desc limit 10',10,24,1}]
<a href="<?=$bqsr['titleurl']?>" target="_blank"><?=$bqr['title']?></a> <br>
[/e:loop]


调用新闻和文章表的头条数据,0指不限有无有标题图片、两个4表示调用4条头条信息、24是指按sql查询:

[e:loop={'select * from (
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_news where firsttitle=1 union
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_article where firsttitle=1
) a order by newstime desc limit 4',4,24,0}]
<a href="<?=$bqsr['titleurl']?>" target="_blank"><?=$bqr['title']?></a> <br>
[/e:loop]

Copyright @ 2013-2021 元素模板 www.ys720.com All Rights Reserved. 版权所有 元素模板 www.ys720.com