"Silently" redirecting to a different controller? |
[eluser]ech0[/eluser]
Hi, I've created a traffic controller, which validates a request and redirects it accordingly. The only problem left, is the URL. The idea is that if I access <b>/about-us/param1/param2</b>, I see the output of <b>/modules/text/2/param1/param2</b> and the actual URL stays the same (<b>/about-us/param1/param2</b>). So basically, is there a way to keep an initial URL, but access different controller's methods (with an option to pass parameters to them)? Thank you in advance!
[eluser]ech0[/eluser]
[quote author="Phil Sturgeon" date="1245604039"]Could URI routing help in this situation?[/quote] The problem is that possible routes are generated dynamically (from a database).
[eluser]ech0[/eluser]
How ugly, in terms of speed, is this kind of solution? <b>routes.php</b>: Code: /*
[eluser]Phil Sturgeon[/eluser]
It's not brilliant but probably no better than pulling from a database. I can think of a solution hacking the Router class dude, but i'll have to do it when im near source code with a little more time. I'm sure its possible.
[eluser]ech0[/eluser]
[quote author="Phil Sturgeon" date="1245613137"]I can think of a solution hacking the Router class dude, but i'll have to do it when im near source code with a little more time. I'm sure its possible.[/quote] I'll stick to my solution for now, but it would be great if you could find a minute or two to put your hands on Router
[eluser]louis w[/eluser]
You might want to check out the Wick Library. I think it's still in beta, but may work for what you need. It allows you to load another controller/method from inside a controller. That way you could move your logic code into a controller instead.
[eluser]Phil Sturgeon[/eluser]
Ahh yes, definitely. Go with Zach's code there. :-)
[eluser]tonanbarbarian[/eluser]
only quickly glanced at this topic so i might be a little off on my idea how about a slight change in the process instead why dont you move what were controllers into libraries then your traffic controller just loads a library and calls a method in the library thereby still following the controller type method only issue with this is you will probably have to load a CI instance in the library to do most of your work, but that is not a major issue. |
Welcome Guest, Not a member yet? Register Sign In |