Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internal forward action in CodeIgniter

In Zend Framework, we can easily forward to an action in another controller using the _forward().

How to simulate this in CI? CI only have redirect but this is not I want, I don't want user to see the URL has changed in their browser.

Any idea to implement it?

like image 285
Howard Avatar asked Feb 02 '26 22:02

Howard


2 Answers

I know for a fact that you can forward to another action inside the same controller without changing the url., with

$this->action();

Other than that, I do not see a built in way to access other controllers

This concept actually seems to break a more strict view of the MVC model, and this functionality you are trying to implement might be better suited for a library.

like image 125
jondavidjohn Avatar answered Feb 05 '26 11:02

jondavidjohn


This sounds like HMVC (Hierarchical MHV) - i.e. controllers being able to load controllers without having to go through the HTTP interface again. You can install a package called Modular Extensions (by wiredesignz). Get the very latest from bitbucket, https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/overview.

Note that support for codeigniter V1.7 has been recently discontinued, so you'll need to user CI V2.0

like image 45
DatsunBing Avatar answered Feb 05 '26 12:02

DatsunBing



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!