寫法(from 官網)
class FooController extends Zend_Controller_Action
{
public function barAction()
{
// Add two actions to the stack
// Add call to /foo/baz/bar/baz
// (FooController::bazAction() with request var bar == baz)
$this->_helper->actionStack('baz',
'foo',
'default',
array('bar' => 'baz'));
// Add call to /bar/bat
// (BarController::batAction())
$this->_helper->actionStack('bat', 'bar');
//加parameters及改變controller, action
$request->setParamSources(array('_POST')) //後記 好像不是這麼用...
->setParams(array(
'log_userid' => $userid
,'log_controller'=>$request->getControllerName()
,'log_action'=>$request->getActionName()))
->setActionName('add')
->setControllerName('Logger');
}
}
參數問題
//利用setParams
$request->setParams(array('param1' => '1')); //param1=1
//也要利用getParams取出
$data = $request->getParams(); //param1=1
echo $data['param1']
redirect問題
不過如果最後是用到redirect的話,actionStack就掛了
最後只好不轉頁,直接把想轉頁的地方加入actionStact
References:
actionstack