Resolved - Best way to load a package module?

Permalink 1 user found helpful
I have a package that has a model and a single page, i need to call the module inside the single page page but im getting an error when i try the loader inside my single page.

Loader::model('MyModel');


so for now im doing it this way;

Loader::model('package');
$pkg = package::getByHandle('my_handle');
include $pkg->getPackagePath().'/models/MyModel.php';


is there a more elegant way to do this? do i need in some way install this module when i install the package so i can call it via the Loader? Thanks for any help.

mdzoidberg
 
Tony replied on at Permalink Reply
Tony
just going from memory here, but i think you need to pass the package in as a second parameter, like:

Loader::model('package',$pkg);

but don't recall whether that's the package object or just the package handle.
ryan replied on at Permalink Best Answer Reply
ryan
Just the handle, doesn't have to be a full package object:
Loader::model('mymodel','package_handle');
mdzoidberg replied on at Permalink Reply
mdzoidberg
Tony, Ryan, Thanks a lot for the help guys, C5 rocks!