Welcome Guest, Not a member yet? Register   Sign In
Call another Controller's function
#1

[eluser]Unknown[/eluser]
Hi,

How do I call another Controller's function

Ex.


class Controller1 extends Controller {

function test1() {}

}

class Controller2 extends Controller {

function test2()
{
How can I call test1() in here considering that they are in 2 diff. controllers?
}

}


Thanks,

Michael Louie Loria
#2

[eluser]sikkle[/eluser]
Humm if you need much method on two controller, think about library or helper, or maybe modular extention stuff.

Take time to read user guide and forum a bit you'll save tons of hours.

see ya around.
#3

[eluser]gtech[/eluser]
seriously search the forums, when I am stuck I search the forums and usually someones already asked the question... scroll down 23 posts you will find someones asked this question today already Smile.

as sikkle suggests the answer is don't call across controllers, it goes against MVC design.

1)create a base controller with common functionality and then extend it (inherit).
2)create a library / helper function and call the function from both controllers.
3)move common logic into the model.

good luck!




Theme © iAndrew 2016 - Forum software by © MyBB