Welcome Guest, Not a member yet? Register   Sign In
re-direct controller to controller
#1

[eluser]bigtime[/eluser]
I've been writing in CI for weeks now and am getting the jist of it, however i have one small issue that still gets me, i'm sick to death of having to copy code from one controller to another.

Is there anyway to re-direct from controller to controller?
#2

[eluser]Rick Jolly[/eluser]
You probably mean something closer to "forward" to another controller - call a method of another controller without redirecting. Anyway, if you find yourself copying code, you should put that code in a helper, library, model, or parent controller.
#3

[eluser]bigtime[/eluser]
ah ok, thanks rick
#4

[eluser]Derek Allard[/eluser]
Depending on what you're looking for, there's also this

Code:
function method1()
{
     // do something here
     $this->method3($somevar);
}

function method2()
{
     // do something here
     $this->method3($somevar);
}

function method3($somevar)
{
     // do something here with $somevar
     return $somevar;
}




Theme © iAndrew 2016 - Forum software by © MyBB