[eluser]jjDeveloper[/eluser]
I came up with something nifty that works for me, feel free to try it out.
In your applications core library if you don't already have one add a subclass of CI_Loader and override the view function like so.
Code:
class MY_Loader extends CI_Loader {
function view($view, $vars = array(), $return = FALSE)
{
$seg = explode('<>', $view);
$out = '';
$ct = 0;
If($seg != FALSE) {
foreach($seg as $dir) {
switch($dir) {
case 'f':
$out .= 'forms/';
break;
case 't':
$out .= 'template/';
break;
case 'r':
$out .= 'registration/';
break;
}
$ct++;
}
$view = $out . $seg[($ct - 1)];
}
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
}
}
To make this function work for your needs however you will have to add case statements for the sub-folders that you wish to abbreviate so to speak.
Lets say in your views you have a folder named content you would just add the following code to the switch statement.
Code:
case 'c':
$out .= 'content/';
break;
The resulting view calls to this folder can now be done using the following load call
Code:
$this->load->view('c<>some_content');
This will also work if you have multi-level sub-folders like this
Code:
$this->load->view('f<>r<>some_view');
This would have the same effect as doing this.
Code:
$this->load->view('forms/registration/some_view');
I find it helps code readability and also results in less typing when you wish to load views out of sub-folders. Keep in mind this addition will still retain the normal functionality if you load the view with its full path as well.
I just thought this might be something you may want to look at. I enjoy using it so hope someone else does too.
Cheers