Search code examples
phpcodeigniterpyrocms

PyroCMS - Loading a custom library in a module


I'm writing a PyroCMS module which involves image upload and thumbnail generation. I'm aware codeigniter has a built in image manipulation class that's capable of making thumbnails, but I'm a big for of phpThumb'ss adaptive resize function. For this reason I'd like to try and get phpThumb working.

I've placed the phpThumb files in ./addons/shared_addons/modules/mymodule/libraries

and I'm trying to load using the following:

$this->load->library('phpThumb/ThumbLib.inc.php');

I'm including the extension because an .inc.php file is not a .php file right? Either way if I keep the extension or not I get this error:

Class 'ThumbLib.inc.php' not found in .../htdocs/system/cms/libraries/MX/Loader.php on line 160

Anyone know what I'm doing wrong?

Thanks, Ed.


Solution

  • The loader naming conventions are probably stricter, so you may need to rename your file to something like 'Thumblib.php' and then declare your class as so class Thumblib {. You may also need to check the library doesn't conflict with anything as is suitable to use in CI.

    Also, I think as long as you are loading the library from a controller in the same module folder tree as the library, the load line should be something like:

    $this->load->library('Thumblib');
    

    Or if not:

    $this->load->library('othermodule/Thumblib');
    

    Good luck.