您现在的位置是:首页 > 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二次开发函数文件目录位置大全
PRinterror()/e/class/connect.phpline 132query()/e/class/db_sql.php line 10fetch1()/e/class/db_sql.php line 30fetch()/e/class/db_sql.php line 22checklevel()/e/cl
帝国CMS教程二次开发统计专题信息数量的方法
本次帝国CMS统计专题信息数量教程主要讲的是列表页list.var的代码写法。其他标签调用同理,只需要小改就可以了。统计的当前专题的信息数量
帝国CMS列表模板list.var如果没有图标就留空的方法
帝国CMS在列表页中,只要信息没有标题图片,就不显示,有标题图片才显示,这样没标题图片的情况下,就不会显示一个X框框。
帝国CMS8.0父子信息调用方法示例代码
帝国CMS8.0版新增父子信息功能,让一条信息也能成为一个信息、一个栏目、一个专题、甚至一个网站。本文共有四个部分:
相关源码
-
(自适应响应式)HTML5幕墙装饰工程建筑装修公司pbootcms模板下载基于PbootCMS开发的响应式模板,为幕墙工程、建筑装饰企业设计,通过数字化展示提升企业专业形象与项目展示能力。结构化数据标记增强项目案例收录,智能URL路由优化,支持每个工程案例独立设置关键词与描述查看源码 -
(自适应响应式)运动健身瑜伽俱乐部网站pbootcms源码下载为健身瑜伽俱乐部设计的响应式网站模板,采用PbootCMS内核开发,可快速搭建专业级企业官网。模板默认适配运动健身行业视觉风格,用户可通过替换图文内容灵活应用于其他服务行业。查看源码 -
自适应新闻资讯技术博客个人网站pbootcms模板该模板基于PbootCMS开源内核深度开发,该模板适用于游戏新闻网站、游戏博客等企业或个人网站,新闻资讯技术博客pbootcms模板;采用六级分辨率断点适配技术查看源码 -
帝国cms7.5模板情感文学名言名句心情文章类源码下载带手机本模板基于帝国CMS7.5开发,为情感文学类网站设计。整体风格温馨雅致,布局合理清晰,特别适合建设情书分享、文学作品展示类网站。模板采用响应式设计,能够自动适配各种终端设备。查看源码 -
响应式WordPress简约博客主题Alt_BlogAlt_Blog主题该模板为博客内容展示设计,采用简约现代的风格理念,打造清晰的内容呈现平台。响应式布局确保在不同设备上都能获得良好的浏览体验,帮助博主更好地展示和分享内容。查看源码 -
(自适应)HTML5响应式双语绿色物流运输快递货运pbootcms源码本款基于PbootCMS开发的网站模板为物流运输、快递货运行业设计,采用HTML5技术构建,支持简繁字体切换。模板设计充分考虑了货运物流行业的特点,可专业展示运输服务、物流网络和业务优势等内容。查看源码
| 分享笔记 (共有 篇笔记) |

