From 341047a9f3de9672a8b007faee6c46de09622929 Mon Sep 17 00:00:00 2001 From: Fredric N Date: Thu, 21 Oct 2010 19:04:22 +0200 Subject: [PATCH] Added support for local/global layouts --- application/Bootstrap.php | 3 +- .../admin/controllers/IndexController.php | 9 ++++++ .../modules/admin/views/layout/default.phtml | 20 +++++++++++++ .../admin/views/scripts/index/index.phtml | 1 + library/Fiktiv/Controller/Plugin/Layout.php | 30 +++++++++++++++++++ 5 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 application/modules/admin/controllers/IndexController.php create mode 100644 application/modules/admin/views/layout/default.phtml create mode 100644 application/modules/admin/views/scripts/index/index.phtml create mode 100644 library/Fiktiv/Controller/Plugin/Layout.php diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 1f1c3c1..fef5e41 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -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; } diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php new file mode 100644 index 0000000..28ee119 --- /dev/null +++ b/application/modules/admin/controllers/IndexController.php @@ -0,0 +1,9 @@ + + + + headTitle() . "\n" /* Newline for pretty source :) */ ?> + headMeta() . "\n" /* Newline for pretty source :) */ ?> + + + headScript() ?> + + fancybox()->headScript() ?> + + +
+ + layout()->content ?> + +
+ + \ No newline at end of file diff --git a/application/modules/admin/views/scripts/index/index.phtml b/application/modules/admin/views/scripts/index/index.phtml new file mode 100644 index 0000000..17967e8 --- /dev/null +++ b/application/modules/admin/views/scripts/index/index.phtml @@ -0,0 +1 @@ +

Admin module, more here later.

\ No newline at end of file diff --git a/library/Fiktiv/Controller/Plugin/Layout.php b/library/Fiktiv/Controller/Plugin/Layout.php new file mode 100644 index 0000000..e999aee --- /dev/null +++ b/library/Fiktiv/Controller/Plugin/Layout.php @@ -0,0 +1,30 @@ +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); + + } +} \ No newline at end of file