Added support for local/global layouts
This commit is contained in:
parent
17c5c48950
commit
341047a9f3
5 changed files with 61 additions and 2 deletions
|
|
@ -48,8 +48,6 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
protected function _initLayout()
|
||||
{
|
||||
$layout = Zend_Layout::startMvc();
|
||||
$layout->setLayoutPath(APPLICATION_PATH . '/modules/default/views/layout');
|
||||
$layout->setLayout('default');
|
||||
|
||||
return $layout;
|
||||
}
|
||||
|
|
@ -103,6 +101,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
// Add plugins
|
||||
$frontController->registerPlugin(new Fiktiv_Controller_Plugin_Language());
|
||||
$frontController->registerPlugin(new Fiktiv_Controller_Plugin_Navigation());
|
||||
$frontController->registerPlugin(new Fiktiv_Controller_Plugin_Layout());
|
||||
|
||||
return $frontController;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
class Admin_IndexController extends Fiktiv_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
20
application/modules/admin/views/layout/default.phtml
Normal file
20
application/modules/admin/views/layout/default.phtml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<?=$this->headTitle() . "\n" /* Newline for pretty source :) */ ?>
|
||||
<?=$this->headMeta() . "\n" /* Newline for pretty source :) */ ?>
|
||||
<link rel="stylesheet" type="text/css" href="<?=$this->baseUrl()?>/css/reset.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="<?=$this->baseUrl()?>/fancybox/jquery.fancybox-1.3.1.css" media="screen" />
|
||||
<?=$this->headScript() ?>
|
||||
<script type="text/javascript" src="<?=$this->baseUrl()?>/fancybox/jquery.fancybox-1.3.1.pack.js"></script>
|
||||
<?=$this->fancybox()->headScript() ?>
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper" class="small">
|
||||
|
||||
<?=$this->layout()->content ?>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1 @@
|
|||
<h1>Admin module, more here later.</h1>
|
||||
30
library/Fiktiv/Controller/Plugin/Layout.php
Normal file
30
library/Fiktiv/Controller/Plugin/Layout.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?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) {
|
||||
|
||||
$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
|
||||
$layout = $bootstrap->getResource('layout');
|
||||
|
||||
$moduleName = $request->getModuleName();
|
||||
|
||||
if (file_exists(APPLICATION_PATH . '/modules/' . $moduleName . '/views/layout/' . $this->_default . '.phtml')) {
|
||||
|
||||
$layout->setLayoutPath(APPLICATION_PATH . '/modules/' . $moduleName . '/views/layout');
|
||||
} else {
|
||||
|
||||
$layout->setLayoutPath(APPLICATION_PATH . '/modules/default/views/layout');
|
||||
}
|
||||
|
||||
$layout->setLayout($this->_default);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in a new issue