get 标签可调用本系统和外部数据,适合熟悉SQL语句的人使用。注意:get标签属性值必须用双引号括起来
1、调用本系统单条数据,示例(调用ID为1的信息,标题长度不超过25个汉字,显示更新日期):
{get sql="select * from phpcms_content where contentid=1" /}
标题:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}
2、调用本系统多条数据,示例(调用栏目ID为1通过审核的10条信息,标题长度不超过25个汉字,显示更新日期):
{get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10"}
标题:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}
{/get}
3、带分页,示例(调用栏目ID为1通过审核的10条信息,标题长度不超过25个汉字,显示更新日期,带分页):
{get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10" page="$page"}
标题:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}
{/get}
分页:{$pages}
4、自定义返回变量,示例(调用栏目ID为1通过审核的10条信息,标题长度不超过25个汉字,显示更新日期,返回变量为 $v):
{get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10" return="v"}
标题:{str_cut($v[title], 50)} URL:{$v[url]} 更新日期:{date('Y-m-d', $v[updatetime])}
{/get}
5、调用同一帐号下的其他数据库,示例(调用数据库为bbs,分类ID为1的10个最新主题,主题长度不超过25个汉字,显示更新日期):
{get dbname="bbs" sql="select * from cdb_threads where fid=1 order by dateline desc" rows="10"}
主题:{str_cut($r[subject], 50)} URL:http://bbs.phpcms.cn/viewthread.php?tid={$r[tid]} 更新日期:{date('Y-m-d', $r[dateline])}
{/get}
6、调用外部数据,示例(调用数据源为bbs,分类ID为1的10个最新主题,主题长度不超过25个汉字,显示更新日期):
{get dbsource="bbs" sql="select * from cdb_threads where fid=1 order by dateline desc" rows="10"}
主题:{str_cut($r[subject], 50)} URL:http://bbs.phpcms.cn/viewthread.php?tid={$r[tid]} 更新日期:{date('Y-m-d', $r[dateline])}
{/get}
7、调用ecshop数据,示例(调用数据源为ecshop,调用产品库中最新的5个产品):
{get dbsource="ecshop" sql="SELECT `goods_id`,`goods_name`,`goods_thumb` FROM `ecs_goods` ORDER BY `goods_id` DESC" rows="5" }
产品ID:{$r[goods_id]}
名称:{$r[goods_name]}
产品图片:{$r[goods_thumb]}
{/get}
phpcms 2008 GET标签使用
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
Linux基本操作命令
wbzjacky
2019-02-24 13:12:38
真实的模拟***综合实验
wbzjacky
2019-02-24 13:12:37
三层交换机的HSRP、vlan、端口聚合
wbzjacky
2019-02-24 13:12:37
HSRP和二层交换机的端口聚合、vlan
wbzjacky
2019-02-24 13:12:37
服务器双机热备解决方案
wbzjacky
2019-02-24 13:12:37
各种光模块的传输距离
realzfd
2019-02-24 13:10:25
ESX4 通过VMware vSphere CLI 开启snmp
realzfd
2019-02-24 13:09:43
SOLARWINDS服务器更改计算机名导致的一次奇怪故障
realzfd
2019-02-24 13:09:42
Dlink交换机常用命令
千年小道
2019-02-24 13:06:21
Sametime的安装细节问题
god9394
2019-02-24 13:04:19
电信禁止路由器上网的破解方法
god9394
2019-02-24 13:03:51