如何获得codeigniter的自定义路径
我使用codeigniter,我正在使用我的维护控制器,但我想知道最好的方法是请求它进入我的维护路线。不确定控制器的布局是否正确 我的路线 //目录最终用户如何获得codeigniter的自定义路径,codeigniter,Codeigniter,我使用codeigniter,我正在使用我的维护控制器,但我想知道最好的方法是请求它进入我的维护路线。不确定控制器的布局是否正确 我的路线 //目录最终用户 $route['maintenance'] = "catalog/common/maintenance";// Need to request this route. $route['account/login'] = "catalog/account/login"; $route['account/register'] = "catal
$route['maintenance'] = "catalog/common/maintenance";// Need to request this route.
$route['account/login'] = "catalog/account/login";
$route['account/register'] = "catalog/account/register";
维修控制员
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Maintenance extends CI_Controller {
public function index() {
if ($this->config->set_item('config_maintenance')) {
$route = '';
if (isset($this->request->get['route'])) {
$part = explode('/', $this->request->get['route']);
if (isset($part[0])) {
$route .= $part[0];
}
}
// Show site if logged in as admin
$this->load->model('model_setting');
}
}
}
自定义控制器
如果创建自定义控制器,
您可以在_构造函数中检查网站是否处于维护状态。
任何从它继承的东西,都将应用规则
class MY_Controller extends CI_Controller
{
public function __construct()
{
parent::__construct();
// Check to see if the user is anything other than
// admin, and redirect them.
// Do your own authoring here.
if(config_item('maintenance_mode') && $currentuser->group != "admin"){
return $this->load->view('maintenance');
}
}
}