Zend重定向在视图脚本中

时间:2011-06-08 03:30:41

标签: php zend-framework redirect

  1. 是否可以使用zend方法重定向视图脚本?

  2. 或者使用php重定向会更简单:<?php header('Location: $myurl') ?>

1 个答案:

答案 0 :(得分:7)

在您的控制器中(使用位置标题):

$this->_redirect($url);

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

你也可以使用:

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

如果要使用与默认值不同的视图脚本:

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