I have this controller which will simply change the language in a session so I can set it in the bootstrap.
Except I want to change ‘$this->_redirect ( ‘library/recipes/list’ );’ to be the URL of the page they are on. Ive tried a few functions and they dont seem to work.
Im a newbie Zend user, thanks!
class Library_LanguageswitchController extends Zend_Controller_Action {
public function init() {
$this->_helper->layout->disableLayout ();
$this->_helper->viewRenderer->setNoRender ();
}
public function switchAction() {
$session = new Zend_Session_Namespace ( 'whatcould' );
$session->language = $this->_getParam ( 'lang' );
$this->_redirect ( 'library/recipes/list' );
}
}
There is no built-in way to do this afaik. You want to redirect back to the referer, which may or may not be stored in
$_SERVER['HTTP_REFERER'].The best approach I can think of is writing a
Zend_Controller_Action_Helperwith a method signature like thisThen you could use
As an alternative, you could use a custom redirect helper that can achieve the same in one go.