![]() |
Loading libraries in subfolder and reflecting the path in $this - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Loading libraries in subfolder and reflecting the path in $this (/showthread.php?tid=1949) |
Loading libraries in subfolder and reflecting the path in $this - El Forum - 07-06-2007 [eluser]Henrik Pejer[/eluser] Yeah, I know, you are thinking, 'what the hell is he talking about?'. Let me try to explain, ok? I really like the idea that you could arrange you libraries in folders and sub folders. Currently, it would seem, CI will not let you do this, unless you modify some classes. And this is my attempt. I also wanted to have the CI-object, or $this, to reflect the folder structure from where the library was loaded. This is the folder structure, and file, we want to load: application/libraries/core/page.php This is how we would load it: Code: $this->load->library('core/page.php'); And this is how we would call or 'use' our page class: Code: $this->core->page->whatever(); I feel it reflects the structure better. The code below has not been tested much, but I'd like to hear your take on this. Is it a good idea? What kind of checks do you think would be necessary for this not to be too insecure, or dangerous? I've put comments in the file stating where I've made my changes. If you use it and it works: let me know! If its utter crap, dangerous or generally a very bad idea, tell it to the forum so that others don't feel tempted to use it. Happy CI-ing! Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); Loading libraries in subfolder and reflecting the path in $this - El Forum - 07-17-2007 [eluser]aroman[/eluser] nice work pejer ,, its a good habit to organize our classes with subfolders on it. . i will try to use your style . thanks |