Smarty缓层动态内容显示问题
时间:2009-12-24
来源:互联网
大家好,我发现Smarty模板在缓存后,显示动态内容有些问题的。
smarty配置文件:smarty.inc.php
include_once("Smarty/Smarty.class.php"); //包含smarty类文件, 位置在当前项目内
$smarty = new Smarty(); //建立smarty实例对象$smarty
$smarty->config_dir="Smarty/Config_File.class.php"; // 目录变量
$smarty->caching=1; //是否使用缓存,项目在调试期间,不建议启用缓存
$smarty->template_dir = "./templates"; //设置模板目录
$smarty->compile_dir = "./templates_c"; //设置编译目录
$smarty->cache_dir = "./caches"; //缓存文件夹
模板页内容:block.html
<div>
<h3>局部不缓存方式三:使用自定义函数 register_block</h3>
需要在php页面中定义函数smarty_block_自定义块名,并且显示之前先注册<br>
{get_tm}
当前时间:{$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
{/get_tm}
</div>
php页面内容:exp_block.php
header('Context-type:text/html; charset=utf-8;');
require_once 'smarty.inc.php';
function get_times($param, $content, &$smarty){
return $content;
}
$smarty->register_block('get_tm','get_times', false);
$smarty->display('block.html');
insert没有问题的,但是register函数和注册块都是不行啊?
为什么?
请哪位指定一下!!
谢谢!!
smarty配置文件:smarty.inc.php
include_once("Smarty/Smarty.class.php"); //包含smarty类文件, 位置在当前项目内
$smarty = new Smarty(); //建立smarty实例对象$smarty
$smarty->config_dir="Smarty/Config_File.class.php"; // 目录变量
$smarty->caching=1; //是否使用缓存,项目在调试期间,不建议启用缓存
$smarty->template_dir = "./templates"; //设置模板目录
$smarty->compile_dir = "./templates_c"; //设置编译目录
$smarty->cache_dir = "./caches"; //缓存文件夹
模板页内容:block.html
<div>
<h3>局部不缓存方式三:使用自定义函数 register_block</h3>
需要在php页面中定义函数smarty_block_自定义块名,并且显示之前先注册<br>
{get_tm}
当前时间:{$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
{/get_tm}
</div>
php页面内容:exp_block.php
header('Context-type:text/html; charset=utf-8;');
require_once 'smarty.inc.php';
function get_times($param, $content, &$smarty){
return $content;
}
$smarty->register_block('get_tm','get_times', false);
$smarty->display('block.html');
insert没有问题的,但是register函数和注册块都是不行啊?
为什么?
请哪位指定一下!!
谢谢!!
作者: dylan147 发布时间: 2009-12-24
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28