thinkphp 系统配置自定义

2023-08-13  本文已影响0人  魔童转世

修改
application\common\model\Config.php
添加
config['configgroup']=self::getGroupList();config['fixedpage']='dashboard';

public static function refreshFile()
    {
        //如果没有配置权限无法进行修改
        if (!\app\admin\library\Auth::instance()->check('general/config/edit')) {
            return false;
        }
        $config = [];
        $configList = self::all();


        

        foreach ($configList as $k => $v) {
            $value = $v->toArray();
            if (in_array($value['type'], ['selects', 'checkbox', 'images', 'files'])) {
                $value['value'] = explode(',', $value['value']);
            }
            if ($value['type'] == 'array') {
                $value['value'] = (array)json_decode($value['value'], true);
            }
            $config[$value['name']] = $value['value'];
        }
        $config['configgroup']=self::getGroupList();
        $config['fixedpage']='dashboard';
        
        file_put_contents(
            CONF_PATH . 'extra' . DS . 'site.php',
            '<?php' . "\n\nreturn " . var_export_short($config) . ";\n"
        );
        return true;
    }

application\extra\site.php
在这里添加分类

上一篇下一篇

猜你喜欢

热点阅读