教程上讲的:5、局部缓存或者不缓存
我们可以指定缓存页面里的某个部分:
现在smarty的插件目录下顶一个个插件函数:block.cacheless.php,代码如下:<?php
function smarty_block_cacheless($param, $content, &$smarty) {
return $content;
}
?>还要修改smarty里的Smarty _Compiler.class.php,找到下面一行,把true改成false:$this->_plugins['block'][$tag_command] =array($plugin_func, null, null, null, true)然后在页面里可以用这个方法指定缓存:<%$smarty.now%>这里的缓存<cacheless> <br> <%$smarty.now%>这里的不缓存<%/cacheless%>
哪里有Smarty_Compiler.class.php?我怎么找不到
我们可以指定缓存页面里的某个部分:
现在smarty的插件目录下顶一个个插件函数:block.cacheless.php,代码如下:<?php
function smarty_block_cacheless($param, $content, &$smarty) {
return $content;
}
?>还要修改smarty里的Smarty _Compiler.class.php,找到下面一行,把true改成false:$this->_plugins['block'][$tag_command] =array($plugin_func, null, null, null, true)然后在页面里可以用这个方法指定缓存:<%$smarty.now%>这里的缓存<cacheless> <br> <%$smarty.now%>这里的不缓存<%/cacheless%>
哪里有Smarty_Compiler.class.php?我怎么找不到
http://www.smarty.net/docsv2/ja/language.function.insert.tpl
http://code.google.com/p/swoole/source/browse/trunk/libs/module/smarty/Smarty_Compiler.class.php?spec=svn134&r=134其中第813行就是你要修改的内容:
$this->_plugins['block'][$tag_command] =array($plugin_func, null, null, null, true)
可以使用$smarty->register_function($params,&$smarty)阻止插件从缓存中输 出,
还可以使用$smarty->register_block($params,&$smarty)使整篇页面中的某一块不被缓 存。
http://fineli.blog.163.com/blog/static/1862264512012112103029421/