Welcome Guest, Not a member yet? Register   Sign In
how access a function in another controller
#1

[eluser]minhbu[/eluser]
in controller B and i want to access a function in controller A. How do it ?
#2

[eluser]dcunited08[/eluser]
Either the function has to be static or you have to use [url="http://codeigniter.com/wiki/Modular_Extensions_-_HMVC"]Modular Extensions HMVC[/url] or [url="http://code.google.com/p/incendiary/downloads/detail?name=wick-0.80.zip"]Wick[/url], what are you planning to do with it?
#3

[eluser]Xeoncross[/eluser]
My guess is that "the function" should be in a library/model instead of a controller...
#4

[eluser]m4rw3r[/eluser]
You can also make it a static method, and then include the controller file with a normal require and then call Controllername::method().
#5

[eluser]minhbu[/eluser]
i will try to use static method.
Thank you,
ahhhhhh
who have another way ?
#6

[eluser]Unknown[/eluser]
The short is that there really isn't an easy way without either passing the first controller to the second as some type of parameter, using a static method, or making some form of Borg/Singleton structure. Depending on context, the Singleton does seem to be a rather popular feature of the CodeIgniter base anyway...
#7

[eluser]dcunited08[/eluser]
[quote author="minhbu" date="1226387721"]i will try to use static method.
Thank you,
ahhhhhh
who have another way ?[/quote]

Can you please let us know what you are attempting to do?




Theme © iAndrew 2016 - Forum software by © MyBB