I’ve got a number of custom modules that use a few of the same common libraries, in particular my database class.
Is there a place I can put this commonly used class for use in modules via
$this->EE->load->library('mydb');or, is there a way to load that class in one module when it’s located in the libraries folder of another module?
I found a way to do this ..
Create a folder called “libaries” in third_party .. this is for your common module libraries.
Libraries can then be loaded from this folder in two ways, either by specifying path directly (this will load Textile library):
$this->EE->load->library("../third_party/libraries/Textile");.. or adding PATH_THIRD to the array of paths to check for libraries:
$this->EE->load->_ci_library_paths[] = PATH_THIRD; // in constructor
$this->EE->load->library("Textile");haven’t decided yet on which I think is best.. Still feels a bit hacky since there is no official way to do this. The second way is probably only possible because of PHP4 support - if EE was made for PHP5 only that array would be private ..
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.