Skip to content

Instantly share code, notes, and snippets.

@notomato
Created August 17, 2012 09:42
Show Gist options
  • Save notomato/3377474 to your computer and use it in GitHub Desktop.
Save notomato/3377474 to your computer and use it in GitHub Desktop.
Adding a mobile template type
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.
<?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