chrisl-921fb74d
chrisl-921fb74d

Reputation: 23100

Zend redirect in a view script

  1. Is it possible to redirect a view script via using a zend method ?

  2. Or would it just be simpler to use a php redirect: <?php header('Location: $myurl') ?>

Upvotes: 1

Views: 7847

Answers (1)

Maxence
Maxence

Reputation: 13296

In your controller (use location header):

$this->_redirect($url);

or

$redirector = $this->getHelper('Redirector');
/* @var $redirector Zend_Controller_Action_Helper_Redirector */
$redirector->gotoUrl($url);

you can also use:

$redirector->gotoRoute(
    array(
        'action'     => 'my-action',
        'controller' => 'my-controller'
    )
);

If you want to use a different view script than the default:

$this->renderScript('/my-controller/my-view.phtml');

Upvotes: 7

Related Questions