Frage

I use codeigniter latest version. I am building an admin area where can choose to have site on maintenance mode.

The button will be radial. the will click save and will update settings.

What is the best way to create the controller for it. I still would like to be able to view website once logged in to website as I am the administrator.

War es hilfreich?

Lösung

Use two type of controller one for normal user and one for admin in normal user controller constructor check if the user is logged in than check if the user is admin or not and than if not than load a maintanance view

For eaxample

class MY_Controller extends CI_Controller {
    public $maintance_enabled = false;
    function __construct()
    {
        parent::__construct();
        /*
         * check user logged in or admin if not and maintanace mode is enabled than load maintance view and exit
         */
        $this->maintance_enabled = TRUE;
    }
}

class Welcome extends MY_Controller {
    function index()
    {
        if($this->maintance_enabled === TRUE)
          return;
    }
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top