我遇到了名为'auth'(包含tank_auth身份验证库)的模块的配置文件路径问题。
'auth'模块中的每个函数都会加载'tank_auth.php'库,该库在application/modules/auth/config/tank_auth.php
中加载tank_auth配置文件:
function __construct()
{
$this->ci =& get_instance();
$this->ci->load->config('tank_auth', TRUE); //<--- HERE IT IS!!
$this->ci->load->library('session');
$this->ci->load->database();
$this->ci->load->model('tank_auth/users');
// Try to autologin
$this->autologin();
}
在另一个模块中,我将以下调用插入'auth'模块中视图中的函数:
<?php modules::run('auth/cp'); ?>
这让我错误
An Error Was Encountered
The configuration file tank_auth.php does not exist.
我通过改变Tank_auth.php中的__construct函数来解决这个问题,即从'tank_auth'到'auth / tank_auth'的路径。
function __construct()
{
$this->ci =& get_instance();
$this->ci->load->config('auth/tank_auth', TRUE); // <--- ADDED module name
$this->ci->load->library('session');
$this->ci->load->database();
$this->ci->load->model('tank_auth/users');
// Try to autologin
$this->autologin();
}
我的问题是为什么从另一个模块调用的auth函数cp看不到'auth'模块中的配置文件?我不能只使用config('tank_auth', TRUE)
添加模块的名称?
答案 0 :(得分:1)
这就是HMVC模块的设计方式。
$this->ci->load->config('tank_auth', TRUE);
这只会搜索默认的配置文件夹。请参阅official CI HMVC页面的“功能”部分,在控制器的上下文中提到它。