For every new controller and action I create, Zend expects a template file in /views/scripts/controllername. However, I would like to have multiple actions share a single template into which text from a database can be injected.
I currently use a layout and delegate page specific views with echo $this->layout()->content. I tried the following:
class SomeController extends Zend_Controller_Action{
public function someAction() {
$path = $this->view->getScriptPath();
$this->view = new Zend_View();
$this->view->setScriptPath($path);
$this->view->render('default.phtml');
}
}
However, I get an error that the script ‘some/some.phtml’ not found in path. How do I do this correctly?
You have to use ‘default’ (without the extension) and call the method directly (not on the view), e.g.
See Zend_Controller_Action::render
If you want to provide a specific script, use
See Zend_Controller_Action::renderScript