
smarty
文章平均质量分 66
sonia_gintoki
little vegetablebird
展开
-
写模板--Smarty类的编译功能仿写
smarty模板功能:php和html分离=>controller和vieweg:{$str} => 把模板经过编译/解析(compile)变为后者mini.class.php<?php/*smarty模板*/class mini{ // compile编译;template模板;编译是从高语言,编到低语言 //模板和编译后的文件 地址原创 2015-10-17 19:22:59 · 878 阅读 · 0 评论 -
Smarty之单模板多缓存,删缓存,不缓存
单模板多缓存根据id的不同生成不同的的缓存页面;例如商品页,一个模板 goods_id不同,取出商品不同但普通缓存手法,就商品不变了解决方法:display和isCached里添加goods_id参数<?php/*单模板 多缓存display和isCached里添加goods_id参数*/require('../../smarty3/libs/Smarty.class.p原创 2015-10-20 16:47:01 · 537 阅读 · 0 评论 -
Smarty标签运算,控制结构[if,for,foreach,section,while]
Smarty标签运算:在页面上做简单的运算[temp5.html]条件判断if循环结构forforeach用得比较多,foreach例子从数据库取出的数据<?php/*smarty html标签可以运算if elseif else判断for循环foreach循环*/require('../../smarty3/libs/Smarty.class.php');原创 2015-10-19 20:58:24 · 1609 阅读 · 0 评论 -
Smarty之缓存,局部缓存
smarty缓存把页面保存到到磁盘,下次访问直接返回保存内容。不缓存浪费数据库性能,因为刷一次从数据库取一次数据<?php/*smarty缓存解释:把页面保存到到磁盘,下次访问直接返回保存内容。1.开启缓存2配置缓存的生命周期3配置是否缓存,是否从数据库取数据4输出*/require('../../smarty3/libs/Smarty.class.php原创 2015-10-20 13:24:17 · 446 阅读 · 0 评论 -
Smarty之变量调节器
变量调节器 smarty里modify文件对变量进行微调,用函数php文件用上次foreach循环的php,内容就是取出个数组就行html如下 temp5 <!-- 变量调节器 smarty里modify文件 对变量进行微调,用函数,例如时间戳$v.add_time|date_format:"%Y-%m-%d %H:%M:%S",字符串大小写转换$原创 2015-10-20 09:58:01 · 449 阅读 · 0 评论 -
Smarty赋值对象方法,配置简化封装类
赋值对象方法html标签写法{$对象名->属性名/方法名()} temp3 {$man->name} {$man->say()}<?php/*assgin赋值对象smarty配置简化(temp,comp地址)封装到类*/class man{ public $name='八郎'; public function say(){ echo '原创 2015-10-19 15:23:57 · 661 阅读 · 0 评论 -
Smarty之assign赋数组append赋值
assign赋数组过程append赋多个值,成索引数组<?php/*assign 赋值数组append 连续赋值*/require('../../smarty3/libs/Smarty.class.php');$smarty=new Smarty();$smarty->template_dir='./temp';$smarty->compile_dir='./comp';原创 2015-10-18 16:11:25 · 2014 阅读 · 0 评论 -
Smarty标签变量来源
html里{$title}的$title的来源有三种1.assign[之前用到的方法]2.smarty系统保留变量,不用赋值,自动获取3.从配置文件读取的配置变量详细请看注释<?php/*html里{$title}的$title的来源有三种1.assign[之前用到的方法]2.smarty系统保留变量,不用赋值,自动获取3.从配置文件读取的配置变量*/原创 2015-10-18 13:30:06 · 506 阅读 · 0 评论 -
Smarty运用,赋值数组,定界符冲突
下载smarty,www.smarty.net 版本3.1.27<?php/*用真正的smarty模板*///引入类require('../../smarty3/libs/Smarty.class.php');//实例化$smarty=new Smarty();//配置路径$smarty->template_dir='./temp';$smarty->compile_dir=原创 2015-10-18 13:03:13 · 1199 阅读 · 0 评论 -
项目里添加smarty功能步骤
项目里添加smarty功能步骤1把smarty的libs文件夹拷到项目路径下,并写子类<?phpdefined('acc')||exit('acc denied');//加载父类文件require(ROOT.'lib/smarty/Smarty.class.php');class mysmarty extends Smarty{ public function __cons原创 2015-10-25 10:00:45 · 515 阅读 · 0 评论