Base.php 868 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace addons\blog\controller;
  3. use think\addons\Controller;
  4. use think\Config;
  5. /**
  6. * Blog控制器基类
  7. */
  8. class Base extends Controller
  9. {
  10. // 初始化
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. $config = get_addon_config('blog');
  15. // 设定主题模板目录
  16. $this->view->engine->config('view_path', $this->view->engine->config('view_path') . $config['theme'] . DS);
  17. // 加载自定义标签库
  18. $this->view->engine->config('taglib_pre_load', 'addons\blog\taglib\Blog');
  19. $config['indexurl'] = addon_url('blog/index/index', [], false);
  20. $categorylist = \addons\blog\model\Category::where('status', 'normal')->order('weigh desc,id desc')->cache(true)->select();
  21. $this->view->assign("categorylist", $categorylist);
  22. Config::set('blog', $config);
  23. }
  24. }