27 lines
No EOL
840 B
PHP
27 lines
No EOL
840 B
PHP
<?php
|
|
require_once 'Zend/Controller/Plugin/Abstract.php';
|
|
|
|
/**
|
|
* Load module layout before trying to load global layout
|
|
*/
|
|
class Fiktiv_Controller_Plugin_Layout extends Zend_Controller_Plugin_Abstract
|
|
{
|
|
protected $_default = 'default';
|
|
|
|
public function preDispatch(Zend_Controller_Request_Abstract $request)
|
|
{
|
|
$layout = Zend_Layout::getMvcInstance();
|
|
|
|
$moduleName = strtolower($request->getModuleName());
|
|
|
|
$layoutPath = APPLICATION_PATH . '/modules/' . $moduleName . '/views/layout';
|
|
|
|
if (!file_exists($layoutPath . '/' . $this->_default . '.phtml')) {
|
|
// use the default module's path.
|
|
$layoutPath = APPLICATION_PATH . '/modules/default/views/layout';
|
|
}
|
|
|
|
$layout->setLayoutPath($layoutPath);
|
|
$layout->setLayout($this->_default);
|
|
}
|
|
} |