mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-06 01:52:48 +08:00
完成分类和文章的模板设置
This commit is contained in:
46
app/index/controller/BaseController.php
Normal file
46
app/index/controller/BaseController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace app\index\controller;
|
||||
|
||||
use app\BaseController as AppBaseController;
|
||||
use think\facade\Config;
|
||||
use think\facade\View;
|
||||
use think\helper\Str;
|
||||
|
||||
class BaseController extends AppBaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 是否使用多模板
|
||||
* 仅当名称为空或者指定名称有效,
|
||||
* 使用跨应用,跨控制器,引用模板路径的写法时无效
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $isUseTpls = true;
|
||||
|
||||
public function assign($template,$value)
|
||||
{
|
||||
return View::assign($template,$value);
|
||||
}
|
||||
|
||||
public function fetch($template = '',$vars = [])
|
||||
{
|
||||
if($this->isUseTpls && strpos($template,'@') === false && stripos($template,'/') === false){
|
||||
|
||||
if($template === ''){
|
||||
$config_auto_rule = Config::get('view.auto_rule');
|
||||
if (2 == $config_auto_rule) {
|
||||
$template = $this->request->action(true);
|
||||
} elseif (3 == $config_auto_rule) {
|
||||
$template = $this->request->action();
|
||||
} else {
|
||||
$template = Str::snake($this->request->action());
|
||||
}
|
||||
}
|
||||
return View::fetch(get_system_config('index_tpl_name').$template,$vars);
|
||||
}else{
|
||||
return View::fetch($template,$vars);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user