From 21da52db63a56b809458c1711fffc7564d35fafc Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 2 Feb 2016 17:57:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BView=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/View.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/library/think/View.php b/library/think/View.php index 3db611ff..5a7d6c9d 100644 --- a/library/think/View.php +++ b/library/think/View.php @@ -214,7 +214,7 @@ class View $template = str_replace(['/', ':'], $depr, $template); // 获取当前模块 - $module = MODULE_NAME; + $module = defined('MODULE_NAME') ? MODULE_NAME : ''; if (strpos($template, '@')) { // 跨模块调用模版文件 list($module, $template) = explode('@', $template); @@ -223,11 +223,13 @@ class View defined('THEME_PATH') || define('THEME_PATH', $this->getThemePath($module)); // 分析模板文件规则 - if ('' == $template) { - // 如果模板文件名为空 按照默认规则定位 - $template = CONTROLLER_NAME . $depr . ACTION_NAME; - } elseif (false === strpos($template, $depr)) { - $template = CONTROLLER_NAME . $depr . $template; + if (defined('CONTROLLER_NAME')) { + if ('' == $template) { + // 如果模板文件名为空 按照默认规则定位 + $template = CONTROLLER_NAME . $depr . ACTION_NAME; + } elseif (false === strpos($template, $depr)) { + $template = CONTROLLER_NAME . $depr . $template; + } } return THEME_PATH . $template . $this->config['view_suffix']; } @@ -270,7 +272,7 @@ class View * @param string $module 模块名 * @return string */ - protected function getThemePath($module = MODULE_NAME) + protected function getThemePath($module) { // 获取当前主题名称 $theme = $this->getTemplateTheme($module);