CodeIgniter Forums
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=33556)

Pages: 1 2


Help with helpers - El Forum - 08-31-2010

[eluser]InsiteFX[/eluser]
You create a MY_Controller and place it in your libraries folder.

Then extend all your new controllers from the MY_Controller.

You can place all your duplicated code that you want to run
in the MY_Controller.

This will show you how to do it!

Phil's base classes

InsiteFX


Help with helpers - El Forum - 09-01-2010

[eluser]gyo[/eluser]
@gmask: yeah that is ok, or you can also place the settings in the controller, like:

Code:
$this->load->helper('my_helper');

$settings = settings();
$this->load->view('index', $settings);

This way the variables are 'prettier' inside the view, where you can just use $title, $location, $tagline.

But, if you need that piece of code EVERYWHERE, the suggestion of InsiteFX to use MY_Controller is very recomendable.