Mobility Support a quick how to.

Posted by Will on 1259783860
I get a lot of people asking me how to do themes and templates for mobile phones - and by the time they get to me with the question they are often so frustrated that they are ready to give it all up.

Well, it doesn't have to be that way - and I will show you here how friggin easy it is. Especially for newer smartphones - like the iphone.

Let's start in your theme folder.

rename theme.html to web.html and create a new blank file called theme.html.

in the new theme.html paste the following snippet of code

<{php}> if (stristr($_SERVER['HTTP_USER_AGENT'],'iPhone')) { include 'iphone.html'; } else { include 'web.html'; } <{/php}>

save it - and create a new file called iphone.html

you now have the ability to fully code out a custom theme for your iphone visitors without any need for a module - or core hacks of any kind. Moreover you can do this for any user agent and it will work flawlessly if the user agent is reported. If the user agent is not reported it will default to web.html. This will also work in template files - so if you have an issue with the way your forums display on iphone - just make a web_template.html and an iphone_template.html and use the code above to trigger which is loaded from the original template.

This couldn't get more simple - but on large sites - it can prove to be a lot of work. However - you could not ask for more control over your site than with this approach.

Anyway - i hope this helped some of you :)

This Post was from: