Welcome Guest, Not a member yet? Register   Sign In
redirect('dashboard', $data)
#1

[eluser]Boyz26[/eluser]
Hi everyone,

Is it possible for me to pass variables to redirects (eg. redirect('index',$data), like we usually pass into $this->load->view('index', $data)?

I tried searching the forum but couldn't find a solution, so I would be grateful if anyone could answer this question.
#2

[eluser]beemr[/eluser]
redirect just sends a redirect header, so the only way to pass data is through the URL. You could redirect to example.com/dashboard/index/user/155.

If dashboard is a method in the same controller, you could just call that method rather than redirecting to it.

Finally, if you don't mind extending the core there are libraries such as Modular Extensions and Matchbox that should provide what you're looking for. I know of a core hack called Controller Forwarding or maybe just Forward that will let you forward your data to the default method of another controller.
#3

[eluser]Colin Williams[/eluser]
If the method is at another controller, you just need to pass it a URI that the other controller method knows how to parse, like beemr said. "Controller Forwarding" seems a bit odd because the destination controller method should already be getting its information from the URI, so requesting the correct URI ought to work just fine. If you need to share data between the current request and the redirect, use session flashdata




Theme © iAndrew 2016 - Forum software by © MyBB