David David - 1 year ago 267
PHP Question

How to build in 'maintenance mode' in Codeigniter?

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 executing their controller code.

What is the best/simplest practice for doing this?

Answer Source

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()

    if($this->config->item('maintenance_mode') == TRUE) {

Let all controllers in your app inherit from that class.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download