I seem to have a problem with my layout displaying twice. I was wondering if this was caused by something in my front controller plugin (see below) which utilises Zend Layout only for a particular module and not in the main application. Any answers will be much appreciated. Thanks
class My_Controller_Plugin_AdoptLayout extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$moduleName = $request->getModuleName();
if ($moduleName == 'some-module') {
if (!Zend_Layout::isEnabled()) {
$view = new Zend_View(array('encoding' => 'UTF-8'));
$view->addScriptPath(ROOT_DIR . '/modules/some-module/views/scripts/');
$view->doctype('XHTML1_STRICT');
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
Zend_Layout::startMvc();
$layout = Zend_Layout::getMvcInstance();
$layout->setLayout('default');
$layout->setLayoutPath(APPLICATION_PATH . '/modules/some-module/views/scripts/layouts/');
$layout->setView($view);
}
}
}
}