'template' => [
'type' => 'Think',
'view_base' => '',// 前后不带DS
'view_path' => 'view',// 前后不带DS
'view_theme' => '',// pc mobile 前后不带DS
'view_suffix' => 'html',
'view_depr' => DS
],[全局视图层目录] 定义view_ba$this->view->config('view_theme', 'pc');
$this->view->config('view_theme', 'mobile');
$this->view->config('view_theme', 'blue');
$this->view->config('view_theme', 'red');
如不适用模板主题,把config 配置文件view_theme默认配置为空就行注意:return $this->fetch();
return $this->fetch('aa/bb');
return $this->fetch('module_name@aa/bb');自定义渲染$View=View::instance();
return $View->fetch('common@form_build/layout-form',['form_data'=>$form_data],[]);[2.1]、相对视图层+(view_path)+[view_theme]private function parseTemplateFile($template){
.......
//[START] 模板定位修改
if (!isset($this->config['view_path']) || empty($this->config['view_path'])) {
$this->config['view_path'] = 'view';
}
if (!isset($this->config['view_theme'])) {
$this->config['view_theme'] = '';
}
$module = isset($module) ? $module : Request::instance()->module();
if (isset($this->config['view_base']) && !empty($this->config['view_base'])) {
//使用全局视图层目录
$path = APP_PATH . $this->config['view_base'] . DS . $module . DS;
} else {
//使用相对视图层目录
$path = APP_PATH . $module . DS . $this->config['view_path'] . DS;
}
!empty($this->config['view_theme']) && $path .= $this->config['view_theme'] . DS;
//[END] 模板定位修改
.......
}[文件二] think\view\driver\Think //架构函数,注释自动设置view_path为绝对地址
public function __construct($config = [])
{
$this->config = array_merge($this->config, $config);
/*
if (empty($this->config['view_path'])) {
$this->config['view_path'] = App::$modulePath . 'view' . DS;
}
*/
$this->template = new Template($this->config);
}
private function parseTemplate($template){
.......
//[START] 模板定位修改
if (!isset($this->config['view_path']) || empty($this->config['view_path'])) {
$this->config['view_path'] = 'view';
}
if (!isset($this->config['view_theme'])) {
$this->config['view_theme'] = '';
}
$module = isset($module) ? $module : $request->module();
if (isset($this->config['view_base']) && !empty($this->config['view_base'])) {
//使用全局视图层目录
$path = APP_PATH . $this->config['view_base'] . DS . $module . DS;
} else {
//使用相对视图层目录
$path = APP_PATH . $module . DS . $this->config['view_path'] . DS;
}
!empty($this->config['view_theme']) && $path .= $this->config['view_theme'] . DS;
//[END] 模板定位修改
.......
}
ThinkPHP 是一个免费开源的,快速、简单的面向对象的 轻量级PHP开发框架 ,创立于2006年初,遵循Apache2开源协议发布,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多的原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进,已经成长为国内最领先和最具影响力的WEB应用开发框架,众多的典型案例确保可以稳定用于商业以及门户级的开发。