[eluser]Unknown[/eluser]
Dear folks, i am new in this forum. First of all, sorry for my poor english :-)
The sharing of models it's really a common task. In my case, i must use a authentication component like redux_auth for more than one application/module. But this - or other compontents - consist of at least one library, model(s) and configuration files.
The sharing of the libraries is simple: storing into the CI-libraries folder. The sharing of configs are also a simple task (eg. load by 'require_once' into the controller), because commonly they are no dependencies to other classes/modules.
Maybe, there is a short solution with some minor changes at the core code of CI:
* Edit the 'Loader.php' of your CI-Installation (CI 1.7.1, 1.7.2);
* Pickup the 'model'-Method (near to line 115);
* Go to the line (near Line 160):
Code:
.
$model = strtolower($model);
and add this lines:
Code:
.
$model = strtolower($model);
$LoadState = FALSE;
$LoadPath = FALSE;
* Than replace the following statements:
Code:
.
if ( ! file_exists(APPPATH.'models/'.$path.$model.EXT))
{
show_error('Unable to locate the model you have specified: '.$model);
}
by
Code:
.
if( $LoadState === FALSE AND file_exists(APPPATH.'models/'.$path.$model.EXT))
{
$LoadState = TRUE;
$LoadPath = APPPATH;
}
if( $LoadState === FALSE AND file_exists(BASEPATH.'models/'.$path.$model.EXT))
{
$LoadState = TRUE;
$LoadPath = BASEPATH;
}
if ( $LoadState === false )
{
show_error('Unable to locate the model you have specified: '.$model);
}
* Each 'if'-Statement represents one directory lookup. The first match wins and set the LoadPath-Variable.
* Finally, you must modify the 'require_once'-Statement near line 180 from:
Code:
.
require_once(APPPATH.'models/'.$path.$model.EXT);
to
Code:
.
require_once($LoadPath.'models/'.$path.$model.EXT);
This approach works very well for me.
With best regards
[edit] Uuuups, sorry - i take a look at your MY_Loader-Class.
It's basically the same solution :-)