• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Libraries in subfolders

#1
[eluser]Dave Stewart[/eluser]
I've tried this, and it appears not to work. Is this the case?
Cheers,
Dave

#2
[eluser]xwero[/eluser]
There are contributions to patch this. So you are right it doesn't work maybe the load->model path code snippet should be made into a function and put into the codeigniter/common.php file to make it available for all loaded files to use
Code:
last_mile_path($path)
{
    $return = new stdClass();
    
    if (strpos($path, '/') === FALSE)
    {
        $return->dirs = '';
        $return->file = $path;
    }
    else
    {
    $x = explode('/', $path);
    $return->file = end($x);
    unset($x[count($x)-1]);
    $return->dirs = implode('/', $x).'/';
    }

    return $return;
}

#3
[eluser]Dave Stewart[/eluser]
I'm sure if there were collisions in names, CI coudl also warn you, or ask you to specify a different name when loading the library, ie:

Code:
$->this->load->library('nav/navigation','nav');

As it is, I'll cope without.

#4
[eluser]xwero[/eluser]
Good remark i'm going to keep it in mind. I'm busy coming up with code to remove the hardcoded paths and the function i added above gives developers a greater flexibility putting CI related files.

#5
[eluser]Dave Stewart[/eluser]
Sounds useful.
xwero, are you one of CI's core developers?

#6
[eluser]xwero[/eluser]
No i'm a developer with a short attention span Smile And because i'm working with CI i try to find ways to make it better, but if they would pay me for my suggestions i wouldn't say no Wink

#7
[eluser]Dave Stewart[/eluser]
[quote author="xwero" date="1214937978"]No i'm a developer with a short attention span Smile[/quote]

Gotcha! I think that would cover me as well - it's certainly rewarding to aim for elegance.
Are you extending the CI_Loader class then?

#8
[eluser]xwero[/eluser]
At the moment i've made a MY_Common.php and a MY_Loader.php file for testing purposes. i'm going to release them soon. I'm already testing it at the moment on a site in development.

#9
[eluser]Dave Stewart[/eluser]
Looking forward to it.
Cheers,
Dave

#10
[eluser]codex[/eluser]
[quote author="xwero" date="1214936259"]Good remark i'm going to keep it in mind. I'm busy coming up with code to remove the hardcoded paths and the function i added above gives developers a greater flexibility putting CI related files.[/quote]

Does this by any chance mean you're modifying the loader in a way that it will allow you to put files anywhere you want? Thus making it possible to move shared libraries/helpers into a 'shared resources' folder? I saw you had a feature request asking for just that.

Would be pretty handy.

EDIT: this thread http://ellislab.com/forums/viewthread/75217/


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.