CodeIgniter Forums

Full Version: Internal Controller Redirect????
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Freewolf[/eluser]
Is there a way to do an internal redirect within the same controller.

I want to check a few things in one method and if everything is not present to send control back to another method but all within the same controller. Is there a way to do this other than redirect()??

El Forum

[eluser]Narkboy[/eluser]
[quote author="Freewolf" date="1295666066"]Is there a way to do an internal redirect within the same controller.

I want to check a few things in one method and if everything is not present to send control back to another method but all within the same controller. Is there a way to do this other than redirect()??[/quote]

Not currently. You can't call a controller from a controller. Sad It's being looked at I believe.

You'll need to rethink your approach - perhaps have one controller function that checks and performs different actions depending on the results?

/B

El Forum

[eluser]Freewolf[/eluser]
I am not looking to redirect to a controller but to another method within the same controller.
Code:
class Some_controller extends Controller

function Some_controller ()
{ parent::Controller }

function index()
{
// do something
some_call_to_redirect_to_another_method('new_method');
}

function new_method()
{
// do something else now
something_more();
}

Make sense??

I need to do this as the way the user needs to get routed and the urls and the way the rest of the site interacts with this particular controller.

El Forum

[eluser]Narkboy[/eluser]
Did you try
Code:
$this->new_method();
?

As far as I know, there's no reason you can't call a function; you just can't redirect. What have you tried?

/B

El Forum

[eluser]InsiteFX[/eluser]
As Narkboy said!

Code:
class Some_controller extends Controller

function Some_controller ()
{
    parent::Controller
}

function index()
{
    if (TRUE)
    {
        // do normal stuff here
    }
    else
    {
        // do something else, call other method!
        $this->new_method();
    }
}

function new_method()
{
    // do something else now
    something_more();
}

InsiteFX