<?php
class Pampa_Plugin_Layout extends Zend_Layout_Controller_Plugin_Layout {

    public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
    {
        // Set the layout directory for the loaded module
        $layoutPath = APPLICATION_PATH . '/modules/' . $request->getModuleName() . '/layouts/';
        Zend_Layout::getMvcInstance()->setLayoutPath($layoutPath);

        // Configure the error plugin to use the loaded module
        // so we can use module-specific error handling
        $frontController = Zend_Controller_Front::getInstance();
        $errorPlugin     = $frontController->getPlugin('Zend_Controller_Plugin_ErrorHandler');
        $errorPlugin->setErrorHandlerModule($request->getModuleName());
    }

}