SMARTY局部缓存
时间:2010-07-18
来源:互联网
PHP文件
<?php
$Smarty = new Smarty();
$Smarty ->caching = true;
$Smarty ->cache_lifetime = 30;
$Smarty ->cache_dir = './library/Smarty/cache';
$Smarty ->compile_dir = './library/Smarty/templates_c/';
$Smarty ->template_dir = './templates/index';
function smarty_block_nocache($param, $content, &$Smarty){
return $content;
}
$Smarty->register_block('nocache', 'smarty_block_nocache', false);
$aa=array([0]=>array([title]=>"a",[hit]=>"1"),[1]=>array([title]=>"b",[hit]=>"2"));
$Smarty->assign("news",$aa);
$Smarty->display('index.html');
?>
index文件
<{foreach from=$news item=news}>
<h2>标题:<{$news.title}></h2>
<h5>浏览: <{nocache}><{$news.hit}><{/nocache}></h5>
<{/foreach}>
为什么刷新下浏览就没有值了呢··请帮忙!
作者: jekom 发布时间: 2010-07-18
我估计:foreach上面的都缓存了,第二次并没有news.hit这个变量
作者: jlzan1314 发布时间: 2010-07-18
<{foreach from=$news item=news}>
<h2>标题:<{$news.title}></h2>
<h5>浏览: <{$news.hit}></h5>
<{/foreach}>
<{/nocache}>
试试.
作者: jlzan1314 发布时间: 2010-07-18
恩,我检查了下第二次news.hit这个变量确实没值,我就搞不懂为什么会没值
作者: jekom 发布时间: 2010-07-18
作者: yanwen249 发布时间: 2010-07-19
作者: jekom 发布时间: 2010-07-22
作者: jimoxly1103 发布时间: 2010-07-23
作者: lwmhy 发布时间: 2010-07-23
作者: woiskobe 发布时间: 2010-07-23
作者: jekom 发布时间: 2010-08-02
------------------
这是什么数组 ? php的语法写数组是这样的吗? 还是楼主把浏览器打印出来的直接贴上去?
PHP code
$aa = array( array( 'title' => 'a', 'hit' => '1' ) ); //换成这样,有值吗? <{foreach from=$news item=new}> <h2>标题:<{$new.title}></h2> <h5>浏览: <{nocache}><{$new.hit}><{/nocache}></h5> <{/foreach}>
作者: coolesting 发布时间: 2010-08-02
from=$news item=old
作者: coolesting 发布时间: 2010-08-02
作者: jekom 发布时间: 2010-08-04
array(
'title' => 'a',
'hit' => '1'
)
);
//换成这样,有值吗?
<{foreach from=$news item=new}>
<h2>标题:<{$new.title}></h2>
<h5>浏览: <{nocache}><{$new.hit}><{/nocache}></h5>
<{/foreach}>
====================================
这样还真有值``
作者: jekom 发布时间: 2010-08-04
作者: hzg0403 发布时间: 2011-12-21
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28