We've recently run into some caching issues which prohibited us from using 3rd-party PHP mobile device detection scripts. Given how frequently mobile versions of sites are requested, it would be great if there were some built-in functionality for swapping out templates/files for mobile users, either incorporating user_agent to or tags. I have more specific ideas for how it could work, but wanted to see what Vae's initial feeling was on the mobile-detection question.
Great! One caveat of note is that sometimes you want tablets to be treated as mobile and other times you don't. So maybe that could be a site-level settings checkbox?
This one is ideal:
http://wurfl.sourceforge.net/
I have also used these before:
http://code.google.com/p/php-mobile-detect/
http://mobiforge.com/developing/story/lightweight-device-detection-php
If none these seem workable, I can find some others.
I agree with Michael, just having the User-Agent available would make it trivial to monkey patch $_REQUEST object with something like this:
__vae.php:// From https://gist.github.com/1503252
$pattern = '/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/';
$_REQUEST['mobile'] = preg_match($pattern, $_SERVER['HTTP_USER_AGENT']);
template.html:<v:if param="mobile">Hello mobile!</v:if>
It looks like you're new here. If you want to get involved, click one of these buttons!