On Thursday 01 April 2010 15:58:07 Diego Potapczuk wrote:
>I'm trying to specify a layout for a module but the old way is not working
>anymore, don´t know if something has changed.
The default layout plugin will accept a stack of paths in LIFO order. This
allows a very simple hack to always ensure that any module can have it's own
default layout which will automatically override the default module layout.
class App_Controller_Plugin_Layout extends Zend_Controller_Plugin_Layout
{
public function __construct ($layout = null)
{
parent::__construct ($layout);
}
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
// Insert current module layout dir to to overide any default layouts
if ( $request->getModuleName() != 'default' ) {
$layoutPath = APPLICATION_PATH . '/modules/' .
$request->getModuleName() . '/views/layouts';
$paths = array();
$paths[] = $this->getLayout()->getViewScriptPath();
$paths[] = $layoutPath;
$this->getLayout()->setViewScriptPath($paths);
}
}
}
Asssuming you set the following application config value:
resources.layout.layout = "default"
Now any module with a default.phtml layout will override the default module
layout.
e.g APPLICATION_PATH/modules/foobar/views/layouts/default.phtml
Cheers the noo,
Graham
--
“What can be asserted without proof can be dismissed without proof.”
- Christopher Hitchens