[PHP] CodeIgniter加上phpcms的模板机制 2 →→→→→进入此内容的聊天室

来自 , 2020-04-22, 写在 PHP, 查看 152 次.
URL http://www.code666.cn/view/b91b1fac
  1. if ( ! function_exists('template'))
  2. {
  3.     /**
  4.      * 模板调用
  5.      *
  6.      * @param $module
  7.      * @param $template
  8.      * @param $istag
  9.      * @return unknown_type
  10.      */
  11.     function template($module = 'expatree', $template = 'index', $style = 'expatree',$return_full_path=true) {
  12.         global $CI;
  13.         if(!isset($CI))$CI =& get_instance();
  14.         if(!$style) $style = 'default';
  15.         $CI->load->library('template_cache','template_cache');
  16.         $template_cache = $CI->template_cache;
  17.         //编译模板生成地址
  18.         $compiledtplfile = $template_cache->cache_path.DIRECTORY_SEPARATOR.'caches_template'.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.EXT;
  19.         //视图文件
  20.         $tplfile= APPPATH.'views'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.EXT;
  21.         if(file_exists($tplfile)) {
  22.             if(!file_exists($compiledtplfile) || (@filemtime($tplfile) > @filemtime($compiledtplfile))) {    
  23.                 $template_cache->template_compile($module, $template, $style);
  24.             }
  25.         } else {
  26.             //如果没有就调取默认风格模板
  27.             $compiledtplfile = $template_cache->cache_path.DIRECTORY_SEPARATOR.'caches_template'.DIRECTORY_SEPARATOR.'default'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.EXT;
  28.             if(!file_exists($compiledtplfile) || (file_exists($tplfile) && filemtime($tplfile) > filemtime($compiledtplfile))) {
  29.                 $template_cache->template_compile($module, $template, 'default');
  30.             } elseif (!file_exists($tplfile)) {
  31.                 show_error($tplfile ,  500 ,  'Template does not exist(0)');
  32.             }
  33.         }
  34.  
  35.         if($return_full_path)
  36.             return $compiledtplfile;
  37.         else
  38.             return 'caches_template'.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template;
  39.     }
  40. }
  41.  

回复 "CodeIgniter加上phpcms的模板机制 2"

这儿你可以回复上面这条便签

captcha