在升级到3.1.3并使用Layout后,官方示例无法正常运行

浏览:622 发布日期:2013/06/28
3.1.3 - 严重 - 未处理
1. 配置 'LAYOUT_ON'=>true,并定义对应的layout文件。
2. 试用快速入门中CUMD代码http://www.thinkphp.cn/info/101.html
3. 在新增数据或者更新数据出错的情况下,比如提交更本没有更新的数据,会导致页面空白。

原因:
在成功或者失败的时候,系统会使用dispatch_jump文件。
使用这个文件会使得view.class.php中的parseTemplate函数直接返回
public function parseTemplate($template='') {
if(is_file($template)) {
return $template;
}
这就会使ThinkTemplate.class.php中112行发生错误
$layoutFile = THEME_PATH.C('LAYOUT_NAME').$this->config['template_suffix'];
$tmplContent = str_replace($this->config['layout_item'],$tmplContent,file_get_contents($layoutFile));
因为THEME_PATH未定义,所以$layoutFile 会是一个不可用的路径。

我的解决办法是加上对THEME_PATH未定义的判断。
if(defined('THEME_PATH'))
{
$layoutFile = THEME_PATH.C('LAYOUT_NAME').$this->config['template_suffix'];
$tmplContent = str_replace($this->config['layout_item'],$tmplContent,file_get_contents($layoutFile));
}
评论(
后面还有条评论,点击查看>>