栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP > php开源框架 > tpAdmin

模板主题支持 - tpAdmin 文档

tpAdmin 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

模板主题支持 - tpAdmin 文档


该主题支持参考 [ThinkPHP3.2 - 模板主题](http://document.thinkphp.cn/manual_3_2.html#template_theme),因很多网友呼吁,官方仍未推出支持模板主题的更新,我自己修改代码,完美支持主题
>[info]tpadmin管理后台并未主动使用模板主题,无论是否修改代码支持模板主题,都不会影响管理后台正常运行

##使用方法
在控制器里模板输出时加上theme方法:
```
// 继承 thinkController 控制器时
return $this->theme('blue')->fetch();
// 或者
$this->theme('blue')->display();

// 没有继承 thinkController 控制器时
$view = thinkView();
return $view->theme('blue')->fetch();
// 或者
$view->theme('blue')->display();

// 全局设置默认模板主题
// 在 config.php 配置文件里加上
'template' => [
// 默认主题
'default_theme' => 'blue'
],
```
>[info]主题为空时表示不使用主题,不使用主题时view模板文件路径和以前一样,例如AdminGroup的模板文件在view/admin_group
protected function theme($theme = '')
{
$this->view->theme($theme);
return $this;
}
```
>[danger]thinkphp/library/think/View.php 第 171 行:
```

public function theme($theme = '')
{
$this->config('default_theme', $theme);
return $this;
}
```
>[danger] thinkphp/library/think/view/driver/Think.php 第 35 行和第 131 行:(如果使用其他模板引擎驱动,请参照该文件修改)
```
// 第35行
// 模板主题 tianpian
'default_theme' => '',

// 第131行:
// 模板主题 tianpian
if ($this->config['default_theme'])
{
$template = $this->config['default_theme'] . DS . $template;
}
```



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/214015.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号