CodeIgniter Forums
Call another controller inside action? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Call another controller inside action? (/showthread.php?tid=28686)



Call another controller inside action? - El Forum - 03-18-2010

[eluser]tkrop[/eluser]
I'm in the process of converting a website from our custom framework to CodeIgniter. Our framework basically returns an ActionResult from every controller action, which can be converted to a string.

This is the situation:

Code:
function ControllerAction($route) {
    $subcontrollerRef = $route->object;
    $page = $route->page;
    $subpage = $route->subpage;

    $controller = ControllerFactory::getController($subcontrollerRef);
    return $controller->$page($route); //dont know if this is syntactically correct, but this is what's going on. The $page function inside the $controller var, is the 'action' name that needs to be executed/returned.
}

Can this be done with CodeIgniter?


Call another controller inside action? - El Forum - 08-08-2010

[eluser]Peter Drinnan[/eluser]
I think this may help.

I more-or-less went through the same painful process as you in converting an exiting pile of proprietary framework files into CI compatible files. Had to deal with content manager block modules by adding a SetInstance() function to Base5.php which allowed me to transfer control to subcontroller blocks, then restore it to the parent (page) using getInstance(). I didn't bother with Base4.php because I never use PHP 4.

Hope this helps ...

http://ellislab.com/forums/viewthread/161260/