문제

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.

도움이 되었습니까?

해결책

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;
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top