可以使用Zend Framework中的redirectory helper传递参数($_POST或$_GET)吗?下面的代码重定向到当前控制器的索引操作,但我也想传递一些参数给它。
$this->_helper->redirector("index");
Zend Documenataion对此只字不提。
发布于 2010-03-31 10:48:17
当然了。这是来自Action Helpers documentation的代码示例(请参阅Redirector
部分,约占页面的2/3 )。您可能需要获取对重定向器帮助器的引用,并调用其中一个goto*
方法,就像下面的代码所做的那样。
class ForwardController extends Zend_Controller_Action
{
/**
* Redirector - defined for code completion
*
* @var Zend_Controller_Action_Helper_Redirector
*/
protected $_redirector = null;
public function init()
{
$this->_redirector = $this->_helper->getHelper('Redirector');
}
public function myAction()
{
/* do some stuff */
// Redirect to 'my-action' of 'my-controller' in the current
// module, using the params param1 => test and param2 => test2
$this->_redirector->gotoSimple('my-action',
'my-controller',
null,
array('param1' => 'test', 'param2' => 'test2'));
}
}
发布于 2013-04-19 19:39:14
将数组作为第四个参数传递:
$this->_helper->redirector('action', 'controller', 'module', array('param1' => 'value1'));
https://stackoverflow.com/questions/2552153
复制