How to build in 'maintenance mode' in Codeigniter?

前端 未结 6 1471
醉酒成梦
醉酒成梦 2020-12-15 00:20

I\'m using latest codeigniter and I need to create a flag (ideally in the config) when turned to \'true\', all pages display a \'maintenance mode\' message instead of execut

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 00:36

    Extend the CI_Controller by putting a new file in your core directory called MY_Controller.

    In this file's constructor, do something like this:

    public function __construct()
    {
        parent::__construct();
    
        if($this->config->item('maintenance_mode') == TRUE) {
            $this->load->view('maintenance_view');
            die();
        }
    }
    

    Let all controllers in your app inherit from that class.

提交回复
热议问题