Move some of the view related code from the Module class to the layout view script
authorRob Allen <rob@akrabat.com>
Sun, 29 Jan 2012 14:44:32 +0000 (14:44 +0000)
committerRob Allen <rob@akrabat.com>
Sun, 29 Jan 2012 14:44:32 +0000 (14:44 +0000)
module/Application/Module.php
module/Application/view/layout/layout.phtml

index 0b428d0..a798668 100644 (file)
@@ -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 = '<script src="' . $basePath . '/js/html5.js"></script>';
-        $view->plugin('placeHolder')->__invoke('html5js')->set($html5js);
-        $favicon = '<link rel="shortcut icon" href="' . $basePath . '/images/favicon.ico">';
-        $view->plugin('placeHolder')->__invoke('favicon')->set($favicon);
+        $view->plugin('basePath')->setBasePath($basePath);
 
         $this->view = $view;
         return $view;
index a9e37b8..00c4478 100644 (file)
@@ -1,9 +1,27 @@
-<?php echo $this->doctype() ?>
+<?php 
+$this->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();
+?>
 
 <html lang="en">
   <head>
     <meta charset="utf-8">
-    <?php echo $this->headTitle() ?>
+    <?php echo $this->headTitle('ZF2 Skeleton Application') ?>
 
     <?php echo $this->headMeta() ?>
 
       }
     </style>
 
-    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
-    <!--[if lt IE 9]>
-      <?php echo $this->placeholder('html5js') ?>
-    <![endif]-->
-
+    <!-- Scripts -->
     <?php echo $this->headScript() ?>
 
-    <!-- Le fav and touch icons -->
-    <?php echo $this->placeholder('favicon') ?>
-
   </head>
 
   <body>