Reputation: 238647
This is what I want to do:
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
//some code
$this->view->var = 'something';
}
public function differentAction()
{
//here, I want to execute the indexAction, but render the differentAction view script
}
}
How can I execute the code from a different action, but render the current view script? I want the view variable to apply to the differentAction view script.
Upvotes: 0
Views: 722
Reputation: 11366
You might also consider making a private / protected method:
class IndexController extends Zend_Controller_Action
{
private function _sharedCode
{
$this->view->var = 'something';
}
public function indexAction()
{
$this->_sharedCode();
}
public function differentAction()
{
$this->_sharedCode();
}
}
Upvotes: 1
Reputation: 238647
Apparently it's as easy as calling $this->indexAction()
. =/
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
//some code
$this->view->var = 'something';
}
public function differentAction()
{
$this->indexAction(); //still renders the differentAction() view script.
}
}
Upvotes: 4