This is my solution how to use viewRenderer , smarty and master page layout.
class Sog_Controller_Action_Helper_ViewRenderer extends
Zend_Controller_Action_Helper_ViewRenderer{
protected $_displayTpl='main.tpl';
protected $_mainVar="middle";
public function changeMain($tplFile)
{
$this->_displayTpl = $tplFile;
}
public function getMain()
{
return $this->_displayTpl;
}
public function noDisplay()
{
$this->_displayTpl = null;
parent::setNoRender();
}
public function changeMainVar($var)
{
$this->_mainVar=$var;
}
public function getMainVar()
{
return $this->_mainVar;
}
public function display($tplFile)
{
$request = $this->getRequest();
$controller = $request->getControllerName();
$action = $request->getActionName();
if (is_null($tplFile)) {
$tplFile =$controller.DIRECTORY_SEPARATOR.$action.'.tpl';
}
$this->changeMain($tplFile);
parent::setNoRender();
}
}
class Sog_Controller_Plugin extends Zend_Controller_Plugin_Abstract {
public function dispatchLoopShutdown()
{
$front=Zend_Controller_Front::getInstance();
$smarty=$front->getParam('smarty');
$viewrender=Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer');
$displayTpl = $viewrender->getMain();
if(!is_null($displayTpl)) {
$response=$front->getResponse();
$body=$response->getBody();
$var=$viewrender->getMainVar();
$smarty->$var=$body;
$response->setBody($smarty->getEngine()->display($displayTpl));
}
}
}
You also need a smarty class which implements View interface.