From 65f13177c2bdc1018aa6d72bd0652ec0b352b5a8 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 2 Dec 2016 22:14:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=A8=A1=E6=9D=BF=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E7=B1=BBparseTemplateFile=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Template.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/library/think/Template.php b/library/think/Template.php index 0c2265c0..74407d62 100644 --- a/library/think/Template.php +++ b/library/think/Template.php @@ -12,6 +12,7 @@ namespace think; use think\exception\TemplateNotFoundException; +use think\Request; /** * ThinkPHP分离出来的模板引擎 @@ -1061,14 +1062,18 @@ class Template { if ('' == pathinfo($template, PATHINFO_EXTENSION)) { if (strpos($template, '@')) { - // 跨模块调用模板 - $template = str_replace(['/', ':'], $this->config['view_depr'], $template); - $template = APP_PATH . str_replace('@', '/' . basename($this->config['view_path']) . '/', $template); - } else { - $template = str_replace(['/', ':'], $this->config['view_depr'], $template); - $template = $this->config['view_path'] . $template; + list($module, $template) = explode('@', $template); } - $template .= '.' . ltrim($this->config['view_suffix'], '.'); + if (0 !== strpos($template, '/')) { + $template = str_replace(['/', ':'], $this->config['view_depr'], $template); + } + if ($this->config['view_base']) { + $module = isset($module) ? $module : Request::instance()->module(); + $path = $this->config['view_base'] . ($module ? $module . DS : ''); + } else { + $path = $this->config['view_path']; + } + $template = $path . $template . '.' . ltrim($this->config['view_suffix'], '.'); } if (is_file($template)) {