帝国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多表调用最新信息的方法
这篇文章主要为大家介绍了帝国CMS多表调用最新信息的方法,主要通过灵动标签的sql语句调用结合union来实现,是非常实用的技巧,需要的朋友可以参考下
-
帝国CMS判断是否有内容分页的方法
帝国CMS判断是否有内容分页,有就显示,没有就不显示。以免没有的分页的时候占了一行位子,不是非常美观。
-
帝国CMS商城系统如何实现在线支付后发送订单邮件提醒功能
帝国CMS是个强大的内容管理系统,其商城的功能也很强大,当用户下单,支付后我们怎么知道有用户下单了呢?因为我们不能时时刻刻都在网站后台,不断的刷新页面去看有无订单,最常用的做法是用邮件提醒我们,有人下单了.
-
帝国CMS内容页附件中文显示或者显示代码名称下载
在帝国CMS模板制作中,比如内容页面显示该内容的附件地址,必须显示原始路径地址,或者说想要中文的路径地址。那么就要用以下方法来实现了:
-
帝国cms加载更多时调用对应文章的tags标签和链接
帝国cms如果使用点击加载更多的时候怎么样连gs标签和链接一起循环出来,如果是调用标题,简介,浏览,时间,这些单一的字都很简单