From d96a037e490b4fb8221263dc30fb0f25071b1d4b Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 25 Oct 2016 23:56:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E5=9B=BE=E6=96=87=E4=BB=B6=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E6=94=AF=E6=8C=81=E9=9B=86=E4=B8=AD=E5=BC=8F=E5=AD=98?= =?UTF-8?q?=E6=94=BE=20=E4=B8=8D=E6=94=BE=E5=85=A5=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/view/driver/Think.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/library/think/view/driver/Think.php b/library/think/view/driver/Think.php index 33729b44..db1d9816 100644 --- a/library/think/view/driver/Think.php +++ b/library/think/view/driver/Think.php @@ -24,6 +24,8 @@ class Think private $template; // 模板引擎参数 protected $config = [ + // 视图基础目录(集中式) + 'view_base' => '', // 模板起始路径 'view_path' => '', // 模板文件后缀 @@ -103,18 +105,21 @@ class Think */ private function parseTemplate($template) { + // 分析模板文件规则 + $request = Request::instance(); // 获取视图根目录 if (strpos($template, '@')) { // 跨模块调用 list($module, $template) = explode('@', $template); - $path = APP_PATH . $module . DS . 'view' . DS; + } + if ($this->config['view_base']) { + // 基础视图目录 + $module = isset($module) ? $module : $request->module(); + $path = $this->config['view_base'] . ($module ? $module . DS : ''); } else { - // 当前视图目录 - $path = $this->config['view_path']; + $path = isset($module) ? APP_PATH . $module . DS . 'view' . DS : $this->config['view_path']; } - // 分析模板文件规则 - $request = Request::instance(); $controller = Loader::parseName($request->controller()); if ($controller && 0 !== strpos($template, '/')) { $depr = $this->config['view_depr'];