1. First create a new folder named behavior;
2. Create a new class under the folder, such as the Auth class;
3. Define namespaces
<?php
namespace App\admin\behavior;
Config is stored in JSON configuration data, which is introduced into the model for easy data reading.
Use App\admin\model\config;
The introduction of this is to facilitate the use of prompt methods such as: $this->success (); $this->success ();
Use \traits\controller\jump;
Class auth{
Public Function run () {
$model = Config::find (1);
$data = $model->content;
$data =json_decode ($data, true);
Defined
Config (' ctitle ', $data [' ctitle ']);
Config (' words ', $data [' words ']);
Config (' descript ', $data [' descript ']);
Config (' number ', $data [' number ']);
Config (' phone ', $data [' phone ']);
Config (' address ', $data [' address ']);
}
}
3. In the tag.php file under Application
' App_init ' = [
‘app\admin\behavior\Auth‘] //引入这个类 4.在页面模板调用的时候{:config(‘ctitle‘)};可以在页面上显示把json中的数据读取出来。 这是我的个人理解,有什么不对的地方请多指教。
The use of tp5.0 behavior, can be stored in JSON data, easy to read data.