From ab145e65efd803ce0fc2e3264d80b74217f67d97 Mon Sep 17 00:00:00 2001 From: Rob Allen Date: Sun, 29 Jan 2012 14:44:32 +0000 Subject: [PATCH] Move some of the view related code from the Module class to the layout view script --- module/Application/Module.php | 18 ++++------------ module/Application/view/layout/layout.phtml | 31 ++++++++++++++++++--------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/module/Application/Module.php b/module/Application/Module.php index 0b428d0..a798668 100644 --- a/module/Application/Module.php +++ b/module/Application/Module.php @@ -69,23 +69,13 @@ class Module implements AutoloaderProvider $locator = $app->getLocator(); $view = $locator->get('view'); - $url = $view->plugin('url'); - $url->setRouter($app->getRouter()); - $view->plugin('doctype')->setDoctype('HTML5'); - - $view->plugin('headTitle')->setSeparator(' - ') - ->setAutoEscape(false) - ->append('ZF2 Skeleton Application'); + // Set up view helpers + $view->plugin('url')->setRouter($app->getRouter()); + $view->doctype()->setDoctype('HTML5'); $basePath = $app->getRequest()->getBaseUrl(); - - $view->plugin('headLink')->appendStylesheet($basePath . '/css/bootstrap.min.css'); - - $html5js = ''; - $view->plugin('placeHolder')->__invoke('html5js')->set($html5js); - $favicon = ''; - $view->plugin('placeHolder')->__invoke('favicon')->set($favicon); + $view->plugin('basePath')->setBasePath($basePath); $this->view = $view; return $view; diff --git a/module/Application/view/layout/layout.phtml b/module/Application/view/layout/layout.phtml index a9e37b8..00c4478 100644 --- a/module/Application/view/layout/layout.phtml +++ b/module/Application/view/layout/layout.phtml @@ -1,9 +1,27 @@ -doctype() ?> +headTitle()->setSeparator(' - ') + ->setAutoEscape(false); + +$basePath = $this->basePath(); +$this->headLink()->appendStylesheet($basePath . '/css/bootstrap.min.css'); + +$this->headLink(array( + 'rel' => 'shortcut icon', + 'type' => 'image/vnd.microsoft.icon', + 'href' => $basePath . '/images/favicon.ico', + )); + +// HTML5 shim, for IE6-8 support of HTML elements +$this->headScript()->appendFile($basePath . '/js/html5.js', 'text/javascript', + array('conditional' => 'lt IE9',)); + +echo $this->doctype(); +?> - headTitle() ?> + headTitle('ZF2 Skeleton Application') ?> headMeta() ?> @@ -16,16 +34,9 @@ } - - - + headScript() ?> - - placeholder('favicon') ?> - -- 1.7.10.4