Welcome Guest, Not a member yet? Register   Sign In
calling other controller's hidden function
#1

[eluser]akkumaru[/eluser]
,,,how do i call another controller's hidden function?
i mean a kind of general function that may need to be called often,,?
#2

[eluser]xwero[/eluser]
create a helper or a library.
#3

[eluser]akkumaru[/eluser]
can i load view from helper or library ?
#4

[eluser]xwero[/eluser]
sure just use the get_instance function to get the CI object.
#5

[eluser]akkumaru[/eluser]
,,ooh,,i've got no idea,,
well,, thank you
#6

[eluser]xwero[/eluser]
If you need a function in several controllers you have to make a decision where to put the function.

If the function is only valid for a few controllers you can extend the controller class and put the function there.
If the function needs some configuration that you need for other functions too you put it in a class.
If it needs values that change within a view or controller you better use a helper.

That is a roughly sketched picture on what goes where. There are a lot more ways to get the same result but you have to find out out for yourself which way works best for you.

In libraries and helpers you can use the functionality you added to CI when you call the get_instance function.
Code:
$CI =& get_instance();
But let the functions/methods that call the get_instance function depend on a single application functionality. For example if you autoload the validation library in the application don't assume another application autoloads the validation library too. Always load the things you need in the function you need it in.




Theme © iAndrew 2016 - Forum software by © MyBB