• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with helpers


Without editing anything in the system folder, I'm trying to create a helper that simplifies the core language_helper. I want to make a similar function, but where it echos the value, instead of returning it.

So instead of: echo lang('general_welcome_message'); I could write phrase('general_welcome_message'); to make everything a little easier for the designer.

Here's the code I've got so far.

if ( ! function_exists('phrase'))
function phrase($phrase)
  $CI =& get_instance();
  $phrase = $CI->lang->line($phrase);

  echo $phrase;

This obviously doesn't work, even though the code is copied for the core helper, because this is located in the application folder.

So my question is, how do I make this work?

- In which file did you save that code snippet?
- Have you loaded the appropriate helper file?

I've saved it under application/helpers. I know this would probably work if I was to save it in the system folder, but I'd rater keep all of my changes in the application folder.

What helper file do I need to load? The language helper?

You probably want to call the file MY_language_helper.php, save it under ./application/helpers and load it via


Then it should work.

Does using the MY prefix ignore the default language helper and use the custom one instead?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.