mpm
mpm

Reputation: 20155

How can I build clean redirections in a controller?

Right now when I want to redirect after an action in my controller I need to write :

function anActionAction(){
    $this->redirect("a string url like mysite/controller/action");
}

Is there a way to build the url a cleaner way?

For instance in the view script, if I want to get an action I use the url helper with an array like:

echo $this->url(array('controller'=>'snippets','action'=>'index'));

So is there a way to pass an array instead of a string in the redirect method? Thanks.

Upvotes: 0

Views: 49

Answers (1)

Liyali
Liyali

Reputation: 5693

Use the Redirector Action Helper:

$this->_helper->redirector($action, $controller = null, $module = null, $params = null)

This will indirectly call the gotoSimple() method of this action helper.

Upvotes: 1

Related Questions