Welcome Guest, Not a member yet? Register   Sign In
Accessing a custom library's function in a helper
#3

[eluser]CroNiX[/eluser]
If its from a helper, you need to reference the CI superglobal, just like you do when creating libraries that use CI.
Code:
function some_helper()
{
  //grab our CI instance
  $CI =& get_instance();
  //use normally using the new reference
  $CI->load->view('some_view');

  $CI->load->library('some_library');  
  $data = $CI->some_library->some_method();
  //...
}

Or, if you have already loaded the library in CI, you can reference it in your helper after grabbing the ci instance.

Code:
function some_helper($data)
{
  $CI =& get_instance();
  //library is already loaded in the controller before the helper, just access it
  $CI->some_library->some_method();
}


Messages In This Thread
Accessing a custom library's function in a helper - by El Forum - 02-26-2011, 05:20 AM
Accessing a custom library's function in a helper - by El Forum - 02-26-2011, 07:43 PM
Accessing a custom library's function in a helper - by El Forum - 02-27-2011, 02:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB