Zend Framework Render different view within module/controller Zend Framework Render different view within module/controller php php

Zend Framework Render different view within module/controller


I fixed it by using:

$this->_helper->viewRenderer->renderBySpec('foo', array('module' => 'modulename', 'controller' => 'controllername')); 


Use this statement in your controller:

// Render 'foo' instead of current action script$this->_helper->viewRenderer('foo');// render form.phtml to the 'html' response segment, without using a// controller view script subdirectory:$this->_helper->viewRenderer('form', 'html', true);

from the official doc http://framework.zend.com/manual/en/zend.controller.actionhelpers.html

It is not possible (at the best of my knowledge) to show view of different module. Besides there's no trace of this question in the official doc.


Like you, I have multiple modules and wanted to render an arbitrary view (residing in one module) in the controller of a different module.

This was the only way that I could get it to work, after trying many approaches:

Controller action:

public function xyzAction(){    $this->_helper->layout->disableLayout();    $view = new Zend_View();    $view->setScriptPath(APPLICATION_PATH . '/modules/moduleB/views/scripts/abcBlahBlah');    echo $view->render('yadaYada.phtml');    exit;}