教程上讲的: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?我怎么找不到

解决方案 »

  1.   

    Smarty_Compiler.class.php 是 Smarty2 的! Smarty3 没有
      

  2.   

    用{insert}
    http://www.smarty.net/docsv2/ja/language.function.insert.tpl
      

  3.   

    这个类是模板引擎Smarty中的文件,这个文件的定义在这里可以看到:
    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)
      

  4.   

    我们可以使用{insert}使模板的一部分不 被缓存
    可以使用$smarty->register_function($params,&$smarty)阻止插件从缓存中输 出,
    还可以使用$smarty->register_block($params,&$smarty)使整篇页面中的某一块不被缓 存。
    http://fineli.blog.163.com/blog/static/1862264512012112103029421/