Help with helpers - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Help with helpers (/showthread.php?tid=52898) |
Help with helpers - El Forum - 07-01-2012 [eluser]Mahn[/eluser] Greetings, 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. Code: if ( ! function_exists('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? Help with helpers - El Forum - 07-01-2012 [eluser]PhilTem[/eluser] - In which file did you save that code snippet? - Have you loaded the appropriate helper file? Help with helpers - El Forum - 07-01-2012 [eluser]Mahn[/eluser] 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? Help with helpers - El Forum - 07-01-2012 [eluser]PhilTem[/eluser] You probably want to call the file MY_language_helper.php, save it under ./application/helpers and load it via Code: $this->load->helper('language'); Then it should work. Help with helpers - El Forum - 07-01-2012 [eluser]Mahn[/eluser] Does using the MY prefix ignore the default language helper and use the custom one instead? |