+ -
当前位置:首页 → 问答吧 → Smarty缓层动态内容显示问题

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函数和注册块都是不行啊?
为什么?
请哪位指定一下!!
谢谢!!

作者: dylan147   发布时间: 2009-12-24