您现在的位置是:首页 > cms教程 > 帝国CMS教程帝国CMS教程
帝国CMS灵动标签调用多表多模型文章信息的方法
澜漪2023-01-23帝国CMS教程已有人查阅
导读要提高这条语句在页面中的性能 博主将这个片段写入了自定义页面,这样就能在需要的页面 区域调用出来 而不需要时时访问数据库。

要提高这条语句在页面中的性能 博主将这个片段写入了自定义页面,这样就能在需要的页面 区域调用出来 而不需要时时访问数据库。大约10分钟刷新一次 降低了 大数据下访客每次访问时都要查询多次数据库的巨大压力,帝国7的包含自定义页面可以这么写 。
<?php require(ECMS_PATH.'page1.html');?>
注意:page1.html在根目录。若在t目录则写成“t/page1.html”
或
[includefile]'../../page1.html'[/includefile] 注意:开启“[includefile]”标签 后台--模板--标签--标签管理--修改(选择对应标签)--开启
1、调用多模型的最新文章
[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]
帝国CMS多表调用最新信息,该演示代码为默认数据表下全站最新10条图片信息,自己根据需求可以附加条件,实现全站点击,全站头条,全站推荐等等.
注释:以上多个模型用“Union”连接调用
若只调用图片:要加ispic=1条件
举例:
[e:loop={'select * from (
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_news where newstime and ispic=1 union
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_photo where newstime and ispic=1 union
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_flash where newstime and ispic=1 union
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_article where newstime and ispic=1) a order by newstime desc limit 10',10,24,1}]
<a href="<?=$bqsr['titleurl']?>" target="_blank"><img src="<?=$bqr['titlepic']?>"/><?=$bqr['title']?></a> <br>
[/e:loop]
2、调用多模型的最新文章
[e:loop={'select title,titleurl,titlepic from [!db.pre!]ecms_photo Union All select title,titleurl,titlepic from [!db.pre!]ecms_download Union All
select title,titleurl,titlepic from [!db.pre!]ecms_news',0,24,0}]
<a href="<?=$bqsr['titleurl']?>" target="_blank"><?=$bqr['title']?></a> <br>
[/e:loop]
注释:以上调用的是(图片模型:photo、下载模型:download、新闻模型:news)三个模型的文章
三个模型用“Union All”连接调用
若指定栏目用:where classid in(46,47,51),
若调用推荐在其后追加:and isgood=1,
若指定调用条数在其后追加:limit 10
举例:
多表调用 同时显示“标题”所在的“栏目名称”和“链接” 及以“点击排行”
[e:loop={"select titleurl,title,onclick,classid from phome_ecms_news union all select titleurl,title,onclick,classid from phome_ecms_article order by onclick desc limit 10",1,24,0}]
<LI><A href="<?=$bqsr[classurl]?>" target=_blank><?=$bqsr[classname]?></A> | <A href="<?=$bqsr[titleurl]?>" target=_blank><?=$bqr[title]?></A></LI>
[/e:loop]
3、多表联合查询“主、副”表调用文章
[e:loop={'select * from (
(select id,classid,title,titleurl,titlepic,newstime from [!db.pre!]ecms_download limit 3 )
Union All
(select id,classid,title,titleurl,titlepic,newstime from [!db.pre!]ecms_movie limit 3)
) as A order by newstime desc ',0,24,0}]
<?php
$fb=$empire->fetch1("select *
from
(
(select id,classid,downpath from {$dbtbpre}ecms_download_data_1 where id='$bqr[id]' and classid='$bqr[classid]')
Union All
(select id,classid,downpath from {$dbtbpre}ecms_movie_data_1 where id='$bqr[id]' and classid='$bqr[classid]')
) as A");
$olurl=explode('::::::',$fb['downpath']);
?>
<li><a href="<?=$bqsr['titleurl']?>"><img src="<?=$bqr['titlepic']?>" alt="<?=$bqr['title']?>"></a>
<div><h3 class="title"><?=$bqr['title']?></h3><p>下载地址:<?=$olurl[1]?></p></div>
</li>
[/e:loop]
注释:以上调用的是(下载模型:download、电影模型:movie)两个模型,并电影副表中下载地址“downpath”(电影副表下载地址未调出,因为里面没有东西)
两个模型用“Union All”连接调用
$olurl=explode('::::::',$fb['downpath']); 真实下载地址的分割
很赞哦! ()
相关教程
图文教程
帝国cms统计增加底部访问数统计图片计数器的方法
下载压缩包解压到网站主目录,打开e/public/viewclick/index.php 在
帝国CMS列表页怎么判断是否有标题图
帝国CMS列表页判断是否有标题图片,有标题图一种样式,无标题图的另一种样式。帝国CMS列表页判断是否有标题图代码
帝国cms搜索伪静态的教程(7.5版本测试正常)
以下方法帝国CMS7.5测试有效,其他版本未测试。帝国CMS搜索伪静态方法一、打开esearchindex.php 411行左右,找到:
帝国CMS8.0版新增父子信息功能的使用方法,有什么用?
帝国CMS8.0版新增父子信息功能,让一条信息也能成为一个信息、一个栏目、一个专题、甚至一个网站。
相关源码
-
(自适应)五金配件机械加工设备pbootcms模板免费下载这款基于PbootCMS开发的网站模板为五金配件和机械加工行业设计,采用简洁有力的设计风格,突出工业产品的专业性和可靠性。模板结构清晰,功能完善,能够有效展示各类工业产品的技术参数和应用场景。查看源码 -
(自适应)互联网建站网络公司个人工作室网站模板基于PbootCMS内核开发,围绕「技术方案展示」「成功案例库」「服务流程说明」三大模块构建,支持PC与移动端数据实时同步。附带包含客户评价、行业解决方案的完整测试数据包查看源码 -
自适应建材瓷砖卫浴大理石类pbootcms网站模板源码下载为建材瓷砖、卫浴瓷砖企业打造的高端响应式门户模板,基于PbootCMS内核深度开发。采用前沿HTML5自适应架构,无缝兼容手机端触控交互与PC端展示场景。查看源码 -
(PC+WAP)蓝色低碳环保隔断板装修装饰类网站pbootcms源码下载本款基于PbootCMS开发的网站模板为活动隔断板、装修装饰行业打造,特别适合移动隔断、环保隔断、办公分区等产品的展示与推广。查看源码 -
手机软件APP游戏软件下载网站Pbootcms模板(自适应)基于PbootCMS内核深度开发的网站模板,为移动互联网时代打造。无论是手机APP推广、游戏软件展示,还是各类企业官网需求,本模板都能通过简单的图文替换实现行业无缝切换查看源码 -
(自适应)蓝色五金制品配件管件pbootcms网站源码下载基于PbootCMS内核开发的五金行业专用模板,采用响应式设计架构,确保产品展示在各类移动设备上的呈现。通过模块化布局与工业风视觉设计,帮助五金企业高效展示产品规格、应用场景及技术支持,建立专业可靠的行业形象。查看源码
| 分享笔记 (共有 篇笔记) |

