简体   繁体   English

路由重定向控制器Codeigniter

[英]Routing Redirect Controller Codeigniter

On my routes.php file in codeigniter I have set it up so if my config item maintenance is set to true it will make that as the default controller. 我在codeigniter的route.php文件中进行了设置,因此,如果我的配置项维护设置为true,它将作为默认控制器。

$config['maintenance'] = TRUE;

route.php 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'] = '';
    }
}

The problem I am having is that. 我遇到的问题是。 When it is set to TRUE When I am logged in as admin I would still like the home controller as default controller. 当它设置为TRUE时当我以admin身份登录时,我仍然希望将home控制器用作默认控制器。 I can not seem to make it work. 我似乎无法使其工作。

Maintenance Controller. 维护控制器。

<?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');
        }
    }

}

I have loaded this hmvc $this->load->module and it has seemed to work 我已经加载了这个hmvc $ this-> load-> module,它似乎可以正常工作

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();

            }

        }


    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM