2010-03-16, 18:59:10
(This post was last modified: 2010-03-16, 20:14:32 by kuba.sanitrak.)
Zegnåt Wrote:...I’ll get back to you with one that does check for theme existence (if nobody has beaten me to it by then).I had posted a working example of checking theme existence but deleted it because, although I requested it, I do agree with internet24 that keeping it simple works best.
Code:
add_hook('index-pretemplate','sitc_process');
function sitc_process() {
global $TEMPLATE;
if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') == true) {
if (is_dir(GSTHEMESPATH.'iPhone')) { $TEMPLATE = 'iPhone'; }
}
}
I've actually tweaked it some (see attachment) to change the theme based on $_SERVER["HTTP_HOST"], for example "m.example.com", as this is the recommended way to serve a mobile version of your website.