2
votes

I'm not sure if this is possible, but various posts in the ExpressionEngine forums and in the documentation suggest that I should be able to let ExpressionEngine know what's going on in the CodeIgniter foundation that it's built on.

So, in light of that, I've got a CodeIgniter app, and an ExpressionEngine site. The /system directory is structured like this:

/system

  • /system/codeigniter
  • /system/codeigniter/application (this is my existing CodeIgniter application)
  • /system/codeigniter/system (this is the same CI folder that EE runs from)

  • /system/expressionengine

  • ... (this is the normal EE - templates, add-ons, etc.

I'm fairly new to ExpressionEngine, but my understanding was that I could use this setup to built an EE module that would integrate well with CodeIgniter.

Currently, I have a module setup, and a method in it that does this, just as a starting point:

function __construct()
{
    $this->EE =& get_instance();
    $this->CI =& get_instance();
    $this->auth =& $this->CI->load->library('mylibrary');
}

But then it doesn't recognize the library when I load the module (this is all happening inside the EE control panel, at this point, just so I can make a connection between the two). Says it doesn't exist. Is there anything I can do to make this connection, or am I going the wrong direction entirely?

Thanks, Jonathan

3

3 Answers

2
votes

Okay, thanks to http://expressionengine.com/forums/viewthread/208140/ I have an answer I think I can build upon.

Here's how it works, for posterity's sake:

EE and your module don’t know at all about your system/codeigniter/application folder. Try this, it > might work:

$this->EE =& get_instance();
$this->EE->load->add_package_path(BASEPATH.'../application/');
$this->EE->load->library('mylibrary');
$this->EE->mylibrary->do_stuff();

From there I was able to load my library, but it had issues loading its language file. The same thread gave an answer to that, as well. This code goes into the CI library file, and EE translates it as it loads.

$this->ci->lang->load('mylangfile', '', FALSE, TRUE, BASEPATH.'../application/');  
0
votes

In the past I've written simple wrapper add-ons for EE to access the CodeIgniter helpers, etc. Here's an example of a simple wrapper add-on.

Another option, it should be possible to this with PHP, which means you'll need to enable PHP in your template. In short, you load the helper/library/etc and then call the method you want. More info on how to do that in the EE docs.

0
votes

You should simply put your library in /third_party/my_addon/libraries/ folder, then load it like so:

function __construct()
{
    $this->EE =& get_instance();
    $this->auth = $this->EE->load->library('../third_party/mhy_addon/libraries/mylibrary');
}