Welcome Guest, Not a member yet? Register   Sign In
How to make 'global' functions?
#1

[eluser]dsentker[/eluser]
Hi again,

i've got a few, small functions (most of them are one-liner) - i want to access these function from different controllers. Where i have to put these function(s) if i dont want to copy (duplicate) the functions in every controller?
#2

[eluser]Rob Gordijn[/eluser]
you can create your own helper (application/helpers), and put it into the autoload list in your config so it will be avaible everywhere.

cheers.
#3

[eluser]richzilla[/eluser]
Or you can create a MY_Controller, and extend all of your other controllers of this. If you put all of your small functions into your MY_Controller, they will be inherited by all your other controllers.
#4

[eluser]alrightythen[/eluser]
or you can just put the function in an existing helper you're already using like the url_helper
#5

[eluser]jedd[/eluser]
[quote author="dsentker" date="1265206913"]Hi again,

i've got a few, small functions (most of them are one-liner) - i want to access these function from different controllers. Where i have to put these function(s) if i dont want to copy (duplicate) the functions in every controller?[/quote]

Definitely [url="/wiki/MY_Controller"]MY_Controller[/url] is your friend here.




Theme © iAndrew 2016 - Forum software by © MyBB