小李SEO博客

网站优化服务

帝国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 unionselect id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_news where newstime unionselect id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_photo where newstime unionselect id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_flash where newstime unionselect 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 unionselect id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_photo where newstime and ispic=1 unionselect id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_flash where newstime and ispic=1 unionselect 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 Allselect 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首页调用会员信息(两表多表查询)
相关帝国cms文章阅读
  • 帝国CMS强制下载txt文件浏览器带下载进度显示

    一般来说,下载txt会直接打开,把下面的代码放入到下载页面中,就提示下载并可以进度保存了!文件位置(\e\DownSys\class\DownSysFun.php) 找到如下代码(帝国CMS7.5 大概203行左右) //下载 Header(Content...

  • 帝国CMS在内容页调用当前专题名称和链接

    因为帝国CMS 7.0信息页不再有ztid字段,所以直接是查询不到的,但是可以用灵动标签sql调用,具体调下方法如下: 灵动标签sql调用: select ztid from phome_enewsztinfo where classid='$navinfor[classid]' and i...

  • 帝国cms后台登陆时验证码不显示怎么解决

    针对帝国CMS7.0:有得同学开启了后台登陆验证码,但是由于种种原因后台验证码没有显示,然而不填写验证码又无法登陆后台关闭后台验证码,墨鱼给同学们一个解决方案 用工具(一定要用工...

  • 帝国CMS栏目ID+结合项伪静态,支持分页

    跟帝国官方的差不多,只是伪静态了。 没有官方支持的筛选项多,只支持:栏目ID,筛选项,分页。需要其他比如:专题ID模型id模版ID排序等等,可以自己修改。 说明: 一:建立字段时候要用...

  • 帝国cms跨域上传支持定义返回字段和扩展名插件

    小李网络公司介绍帝国cms跨域上传支持定义返回字段和扩展名插件知识,包括跨域是什么帕提亚帝国cors跨域帝国霸主帝国的崛起跨域处理nginx跨域为什么要跨域允许跨域跨域ajax跨域什么意思js跨...

  • 帝国CMS灵动标签调用某个时间段的信息的代码写法!

    用如下方法可以实现了! [e:loop={news,10,18,0,newstime=.to_time(2010-11-11 00:00:01). and newstime=.to_time(2010-11-11 23:59:59)}] a href=?=$bqsr[titleurl]? target=_blank?=$bqr[title]?/abr [/e:loop]...

  • 帝国cms模板隔行变色使用灵动标签实现方法

    小李网络公司介绍帝国cms模板隔行变色使用灵动标签实现方法知识,包括帝国cms标签调用大全帝国cms标签帝国下载站模板帝国cms标签位置帝国网站模板帝国cms首页tags帝国cms描述帝国cms通过tags....

  • 帝国CMS内容页面description调用新闻信息简介

    很多小伙伴问墨鱼为啥新闻页面的description调用的和标题一样,那是因为墨鱼做模板的时候默认description调用的是帝国系统给的标签!--pagedes--]。如果小伙伴要改成调用简介的话请看如下说明:...

  • 帝国CMS会员中心调用会员发布信息总数

    希望在会员中心首页,调用显示会员总共投稿发布了多少篇信息,以帝国CMS7.0为例,代码如下: ?=$empire-gettotal(select count(*) as total from phome_ecms_info where userid='$user[userid]' )? 这是根据数据表查询调...

  • 帝国CMS首页调用已注册会员人数和最新会员名称

    首页调用已注册会员人数和最新会员名称 ?php $members=$empire-gettotal(select count(*) as total from {$dbtbpre}enewsmember);$newmember=$empire-fetch1(select userid,username from phome_enewsmember order by userid desc limit 1);? 会员总...

  • 帝国CMS内容页根据TAG匹配相关文章列表代码

    功能: 比如说有3个TAG,每个TAG下有4篇文章,现在指定要显示10篇文章,那么每个TAG要拿出4篇,共有12篇文章,最终会打乱这12篇文章,然后取10篇 3个TAG,每个TAG下有3篇文章,现在指定要显示...

  • 帝国cms十万级以上数据进行数据分表操作记录

    小李网络公司介绍帝国cms十万级以上数据进行数据分表操作记录知识,包括有些菜单选项为灰色显示对于已有数据的硬盘进行重新分区则信息存储采用什么进制帝国数据银行文件夹是指帝国时代...

SEO公司排名
 
QQ在线咨询
SEM竞价推广
137-1296-7640
SEO优化外包
137-1296-7640