smarty局部缓存
来源:互联网 发布:it域名注册 编辑:程序博客网 时间:2024/04/30 06:20
局部缓存
实时性要求比较高
例如:登陆用户名称
欢迎Amdin登陆到****
例如:时间日期
解决步骤: 自定义函数(自定义插件)
第一种:插件形式
1) 指定该函数名称nocache
2) 新建文件./plugins/block.nocache.php
内容:
<?php
function smarty_block_nocache($args, $content){
return $content;}
?>
3)*.php
….
$tpl->assign(“date,date(“H:i:s”));
….
*.tpl
<{nocache}><{$date}><{/nocache}>
所有插件默认被缓存
Smarty. 712 行
Else{
if($tag_command==nocache){
$this->_plugins['block'][$tag_command] = array($plugin_func, null, null, null, false);}
Else{
$this->_plugins['block'][$tag_command] = array($plugin_func, null, null, null, true);
}
}
第二种:php文件内自定义函数并注册
*.php
$tpl->register_block(“nocache”,”fun1”,false);
function fun1($args,$content){return $content;}
$tpl->assign(“date”,date(“H:i:s”));
*.tpl
<{nocache}><{$date}><{/nocache}>
例如:index.php
$tpl->cache_dir = "./cache/";
$tpl->caching=2;
$tpl->cache_lifetime=60*60*24;
$tpl->register_block("nocache","fun1",false);
function fun1($args,$content){
return $content;
}
$tpl->assign("date",date("H:i:s"));
$tpl->display(“index.tpl”);
index.tpl:
<{nocache}>
<{$date}>
<{/nocache}>
第三种:smarty内建函数insert
定义一个inster标签要使用的处理函数
函数名格式为:
insert_xx(array $params, object &$smarty)
其中的xx是insert的name,也就是说,如果你定义的函数为insert_abc,则模板中使用方法为{insert name=abc}参数通过
$params传入
也可以做成insert插件,文件名命名为:insert.xx.php,函数命名为:smarty_insert_aa($params,&$smarty),xx定义同上
- smarty页面局部缓存
- smarty局部缓存
- smarty局部缓存技术
- smarty 实现局部缓存
- smarty局部缓存
- SMARTY局部缓存
- smarty局部缓存
- smarty局部缓存
- Smarty局部缓存
- smarty局部缓存
- smarty局部缓存
- smarty局部缓存
- smarty局部不缓存
- smarty局部缓存
- smarty 局部不缓存
- smarty的局部缓存
- smarty-缓存(局部不缓存)
- Smarty之缓存,局部缓存
- innerHTML解析JS
- 解析元数据
- SQL DateTime日期格式 CONVERT
- v$sysstat表解释
- SQL Server 2000服务无法启动,提示“系统找不到指定的文件”解决方法及sp4安装不上
- smarty局部缓存
- fla文件与as文件之间的绑定
- QT国际化支持
- smarty分页
- RAID卡原理与设置
- 删除MySQL二进制日志的3种方法
- 如何优化sql语句
- 显示动态动画
- 字符串常量下标引用