如何在Codeigniter中建立“维护模式”? [英] How to build in 'maintenance mode' in Codeigniter?

查看:109
本文介绍了如何在Codeigniter中建立“维护模式”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用最新的codeigniter,我需要创建一个标志(理想情况下在配置)转到真时,所有页面显示维护模式消息,而不是执行他们的控制器代码。



这是最好的/最简单的做法是什么?

解决方案

扩展CI_Controller



在这个文件的构造函数中,执行这样的操作:



<$> p $ p> public function __construct()
{
parent :: __ construct();

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

让应用程序中的所有控制器从该类继承。


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?

解决方案

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.

这篇关于如何在Codeigniter中建立“维护模式”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆