2

I'm creating a custom helper in codeigniter. There is an instance where I check if certain parameter is passed to view.

In view, i can get all the passed variables by using this function:

$this->_ci_cached_vars

but it returns blank when used in the custom helper.

Is there any equivalent function of this that can be used in the helper?

Thanks in advance.

tereško
  • 58,060
  • 25
  • 98
  • 150
Emman Z
  • 171
  • 1
  • 13

3 Answers3

0

_ci_cached_vars is a property of the Loader class. So something like this should work (untested):

$CI =& get_instance();
$vars = $CI->load->_ci_cached_vars;
Aken Roberts
  • 13,012
  • 3
  • 34
  • 40
0

You can use $GLOBALS['CI']->load->get_var('your_key_here') tested in CI 2.1.2

Cody
  • 2,480
  • 5
  • 31
  • 62
0

I'm not sure if older versions of CodeIgniter support this, but in the v3 release the Loader class has a public method get_vars() that allows you to read the value of _ci_cached_vars.

Although this question is very old it's the first hit on Google that I found while searching for this problem. I hope this post helps someone out who follows the same path on Google as I did! :)

Thomas Vervest
  • 2,131
  • 1
  • 16
  • 13