I’m experiencing a problem with the paths of a config file for a module called ‘auth’ (which contains the tank_auth authentication library).
Every function in the ‘auth’ module loads the ‘tank_auth.php’ library which loads the tank_auth config file in application/modules/auth/config/tank_auth.php:
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();
}
In another module, I insert the following call to a function in a view within the ‘auth’ module:
<?php modules::run('auth/cp'); ?>
This gets me the error
An Error Was Encountered
The configuration file tank_auth.php does not exist.
I solve this by changing within the __construct function in Tank_auth.php, the path from ‘tank_auth’ to ‘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();
}
My question is why doesnt the auth function cp that is being called from another module sees the config file within the ‘auth’ module? Shouldnt I be able to just use config('tank_auth', TRUE) without adding in the name of the module?
Thats the way HMVC module is designed.
This will only search in the default config folder. See the “Features” section of the official CI HMVC page where it is mentioned in the context of controllers.