Permalink
Browse files

Different layout based on browser type

  • Loading branch information...
1 parent 221a990 commit 28b86c3cdb6d34c2a5f322d1d126438b631d039d @weierophinney committed Oct 18, 2010
View
@@ -13,6 +13,7 @@ mobile-app=/home/matthew/git/zf-examples/mobile-app CD=. filter="*.php *.phtml *
layouts=layouts {
scripts=scripts {
layout.phtml
+ mobile.phtml
}
}
models=models {
@@ -38,6 +39,11 @@ mobile-app=/home/matthew/git/zf-examples/mobile-app CD=. filter="*.php *.phtml *
README.txt
}
library=library {
+ Ma=Ma {
+ Plugin=Plugin {
+ Layout.php
+ }
+ }
wurfl-php-1.1=wurfl-php-1.1 {
WURFL=WURFL {
Application.php
@@ -2,11 +2,15 @@
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
+autoloaderNamespaces[] = "Ma_"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
+
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
+resources.frontController.plugins[] = "Ma_Plugin_Layout"
+
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.useragent.wurflapi.wurfl_api_version = "1.1"
@@ -0,0 +1,61 @@
+<?php
+$this->placeholder('sidebar')
+ ->setPrefix('<ul class="sidebar">')
+ ->setPostfix('</ul>');
+$this->headTitle('Mobile Device Demo')
+ ->setSeparator(' - ');
+$this->headLink()->prependStylesheet('/css/mobile-demo-desktop.css')
+ ->prependStylesheet('/css/960.css')
+ ->prependStylesheet('/css/text.css')
+ ->prependStylesheet('/css/reset.css');
+
+echo $this->doctype() ?>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
+<?php
+ echo $this->headTitle();
+ echo $this->headLink();
+ echo $this->headScript();
+?>
+</head>
+<body>
+<div class="container_12 application">
+ <div class="grid_12 header">
+ <h1>ZF Mobile Demo</h1>
+ </div>
+ <div class="clear"></div>
+
+ <div class="grid_12 spacer"></div>
+ <div class="clear"></div>
+
+ <div class="grid_12 content">
+ <?php echo $this->layout()->content; ?>
+ </div>
+ <div class="clear"></div>
+
+ <div class="grid_12 spacer"></div>
+ <div class="clear"></div>
+
+ <div class="grid_12 sidebar">
+ <?php echo $this->placeholder('sidebar') ?>
+ </div>
+ <div class="clear"></div>
+
+ <div class="grid_12 spacer"></div>
+ <div class="clear"></div>
+
+ <div class="grid_12 footer1">
+ &copy; 2010 Zend Technologies
+ </div>
+ <div class="clear"></div>
+ <div class="grid_12 footer2">
+ <a href="http://framework.zend.com/manual/en/zend.http.user-agent.html">Zend_Http_UserAgent docs</a>
+ </div>
+ <div class="clear"></div>
+
+ <div class="grid_12 spacer"></div>
+ <div class="clear"></div>
+</div>
+</body>
+</html>
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Switch layout if mobile device detected
+ *
+ */
+class Ma_Plugin_Layout extends Zend_Controller_Plugin_Abstract
+{
+ public function postDispatch(Zend_Controller_Request_Abstract $request)
+ {
+ $front = Zend_Controller_Front::getInstance();
+ $bootstrap = $front->getParam('bootstrap');
+ $ua = $bootstrap->getResource('useragent');
+ $device = $ua->getDevice();
+
+ if ($device->getType() == 'mobile') {
+ Zend_Layout::getMvcInstance()->setLayout('mobile');
+ }
+ }
+}

0 comments on commit 28b86c3

Please sign in to comment.