mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
改进Php模板引擎驱动的模板定位规则
This commit is contained in:
@@ -115,7 +115,9 @@ return [
|
|||||||
'template' => [
|
'template' => [
|
||||||
// 模板引擎类型 支持 php think 支持扩展
|
// 模板引擎类型 支持 php think 支持扩展
|
||||||
'type' => 'Think',
|
'type' => 'Think',
|
||||||
// 模板路径
|
// 视图基础目录,配置目录为所有模块的视图起始目录
|
||||||
|
'view_base' => '',
|
||||||
|
// 当前模板的视图目录 留空为自动获取
|
||||||
'view_path' => '',
|
'view_path' => '',
|
||||||
// 模板后缀
|
// 模板后缀
|
||||||
'view_suffix' => 'html',
|
'view_suffix' => 'html',
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ class Php
|
|||||||
{
|
{
|
||||||
// 模板引擎参数
|
// 模板引擎参数
|
||||||
protected $config = [
|
protected $config = [
|
||||||
|
// 视图基础目录(集中式)
|
||||||
|
'view_base' => '',
|
||||||
// 模板起始路径
|
// 模板起始路径
|
||||||
'view_path' => '',
|
'view_path' => '',
|
||||||
// 模板文件后缀
|
// 模板文件后缀
|
||||||
@@ -109,20 +111,26 @@ class Php
|
|||||||
$this->config['view_path'] = App::$modulePath . 'view' . DS;
|
$this->config['view_path'] = App::$modulePath . 'view' . DS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$request = Request::instance();
|
||||||
|
// 获取视图根目录
|
||||||
if (strpos($template, '@')) {
|
if (strpos($template, '@')) {
|
||||||
|
// 跨模块调用
|
||||||
list($module, $template) = explode('@', $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 {
|
} else {
|
||||||
$path = $this->config['view_path'];
|
$path = isset($module) ? APP_PATH . $module . DS . 'view' . DS : $this->config['view_path'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 分析模板文件规则
|
$depr = $this->config['view_depr'];
|
||||||
$request = Request::instance();
|
|
||||||
$controller = Loader::parseName($request->controller());
|
|
||||||
$depr = $this->config['view_depr'];
|
|
||||||
if (0 !== strpos($template, '/')) {
|
if (0 !== strpos($template, '/')) {
|
||||||
$template = str_replace(['/', ':'], $depr, $template);
|
$template = str_replace(['/', ':'], $depr, $template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$controller = Loader::parseName($request->controller());
|
||||||
if ($controller) {
|
if ($controller) {
|
||||||
if ('' == $template) {
|
if ('' == $template) {
|
||||||
// 如果模板文件名为空 按照默认规则定位
|
// 如果模板文件名为空 按照默认规则定位
|
||||||
|
|||||||
Reference in New Issue
Block a user