Section: Doing a redirection
« Generating HTML content | ^ Classic responses | Generating plain text » |
− Table of content
There are two types of redirection objects available :
- jResponseRedirect : redirects to an action of the application with optional parameters
- jResponseRedirectUrl : redirects to any URL
jResponseRedirect ¶
To specify a redirection to an action, you indicate 'redirect' as the type of response :
$rep = $this->getResponse('redirect');
You have then an instance of jResponseRedirect in $rep.
You have three properties on this object:
- action to indicate the action to redirect (an action selector)
- params to indicate parameters for this actions (optional)
- anchor to indicate an anchor in the url #anchor (optional)
Example:
$rep->action = "module~controller:action";
$rep->params = array('foo' => 'bar');
$rep->anchor = 'yo';
And then
return $rep;
jResponseRedirectUrl ¶
This type of response ("redirectUrl") is used to redirect to an external url (or an url which is not pointing to your application).
$rep = $this->getResponse('redirectUrl');
The single property of this response is url, where you indicate the url to redirect.
$rep->url = "http://jelix.org";
return $rep;