Created
August 17, 2012 09:42
-
-
Save notomato/3377474 to your computer and use it in GitHub Desktop.
Adding a mobile template type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You can easily add support for mobile templates by configuring the Media class. Using the snippet below if the request is made from a mobile device we can first check for a mobile template, and if there is none fall back to the default. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// config/bootstrap/media.php | |
Media::type('mobile', array('text/html'), array( | |
'view' => 'lithium\template\View', | |
'paths' => array( | |
'template' => array( | |
'{:library}/views/{:controller}/{:template}.mobile.php', | |
'{:library}/views/{:controller}/{:template}.html.php', | |
), | |
'layout' => array( | |
'{:library}/views/layouts/{:layout}.mobile.php', | |
'{:library}/views/layouts/{:layout}.html.php', | |
), | |
'element' => array( | |
'{:library}/views/elements/{:template}.mobile.php', | |
'{:library}/views/elements/{:template}.html.php' | |
) | |
), | |
'conditions' => array('mobile' => true) | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment