Archived
1
0
Fork 0
This repository has been archived on 2026-05-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
fiktivkod/library/Fiktiv/Controller/Plugin/Layout.php
2014-05-09 11:26:26 +02:00

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);
}
}