帝国cms小程序开发 帝国cms栏目列表页调用内容页一篇文章

帝国CMS教程

在列表模板使用如下代码插入列表模板中:

[e:loop={"select * from phome_ecms_news where classid='$GLOBALS[navclassid]' limit 1",1,24,0}]<?php$fr=$empire->fetch1("select newstext from phome_ecms_news_data_{$bqr[stb]} where id='$bqr[id]'");?>标题:<?=$bqr[title]?><br>内容:<?=$fr[newstext]?>[/e:loop]

代码说明:

第一句中含有的select * from phome_ecms_news where classid='$GLOBALS[navclassid]'

表示从新闻数据表中phome_ecms_news 选取全部的内容,但是条件是classid='$GLOBALS[navclassid]'表示动态获取当前的栏目或者分类,limit 1,下一个1,表示选择显示条数(好像没用,受到limit 1 SQL语句控制),24,表示操作类型使用sql语法,0,表示不限定是否选择有标题图的文章;

第二句话:

$fr=$empire->fetch1("select newstext from phome_ecms_news_data_{$bqr[stb]} where id='$bqr[id]'");

表示再次选择以上栏目包含的id下的标题文章,newstext 代表文章内容,id='$bqr[id]'表示条件是调用该栏目下的对应的id的文章内容,如果将其更换成id=3,表示调用仅此id这一篇文章,

例如下面的例子:

[e:loop={"select * from phome_ecms_news where classid='$GLOBALS[navclassid]' limit 1",0,24,0}]<?php$fr=$empire->fetch1("select newstext from phome_ecms_news_data_{$bqr[stb]} where id='469'");?><?=$fr[newstext]?>[/e:loop]

注意:limit 1id='$bqr[id]'的使用方式,如果limit 4 表示循环调用出该栏目所有的文章内容

调用截取部分文字信息:

[e:loop={"select * from phome_ecms_news where classid='87' limit 1",0,24,0}]<?php$fr=$empire->fetch1("select newstext from phome_ecms_news_data_{$bqr[stb]} where id='784'");?><?=substr($fr[newstext],0,900)?>[/e:loop]

红色表示截取900个字符从0开始