The controller method _forward()
can accept only the action if it is in the same controller and module as the first action you are forwarding from.
So in your action1Action()
method, you can simply call:
$this->_forward('action2');
If your second action is not in the same module/controller, you could subclass Zend_Controller_Action into your own "base" application controller that all your other action controllers inherit from (a good practice on ZF projects I find) and then create another one called _forwardFromUrl()
or something like that, which breaks your URL apart and passes it to _forward()
(or create an action controller helper if you just need this one extra thing).
This example is simplified and assumes your $url
will always be in the format module/controller/action
:
protected function _forwardFromUrl($url)
{
$parts = array_reverse(explode("/",$url));
$this->_forward($parts[0],$parts[1],$parts[2]);
}
Hope that helps!