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

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

问题描述

我正在使用最新的 codeigniter,我需要在变为true"时创建一个标志(最好在配置中),所有页面都显示维护模式"消息,而不是执行其控制器代码.

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?

推荐答案

通过在名为 MY_Controller 的核心目录中放置一个新文件来扩展 CI_Controller.

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天全站免登陆