路由重定向控制器Codeigniter

时间:2014-09-14 04:23:13

标签: php codeigniter

在codeigniter中的routes.php文件中,我已将其设置为如此,如果我的配置项维护设置为true,则会将其设置为默认控制器。

$config['maintenance'] = TRUE;

route.php

if (!$this->config->item('installed')) {

    $route['default_controller'] = "install/step_1/index";
    $route['404_override'] = '';

} else {

    if ($this->config->item('maintenance') == TRUE) {
        $route['default_controller'] = "catalog/common/maintenance/index";
        $route['404_override'] = '';
    } else {
        $route['default_controller'] = "catalog/common/home/index";
        $route['404_override'] = '';
    }
}

我遇到的问题是。当它设置为TRUE当我以管理员身份登录时,我仍然希望将家庭控制器作为默认控制器。我似乎无法使其发挥作用。

维护控制器。

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Maintenance extends MX_Controller {

    function __construct() {
        parent::__construct();
    }

    public function index() {

        if ($this->config->item('maintenance')) {

            $this->load->library('user');

            if(!$this->user->isLogged()) {
                $this->info();
            } else {

                // Should Allow Me To View Home Controller 
            }

        }


    }

    public function info() {
        if (file_exists(DIR_TEMPLATE . $this->configs->get('config_template') . '/template/common/maintenance.php')) {
            return $this->load->view($this->configs->get('config_template') . '/template/common/maintenance');
        } else {
            return $this->load->view('default/template/common/maintenance');
        }
    }

}

1 个答案:

答案 0 :(得分:0)

我已经加载了这个hmvc $ this-&gt; load-&gt;模块,它似乎可以正常工作

public function index() {

        if ($this->config->item('maintenance')) {

            $this->load->library('user');

            if(!$this->user->isLogged()) {

                $this->info();

            } else {

                $this->load->module('catalog/common/home');
                $this->home->index();

            }

        }


    }