Hello all, I was having a problem getting the mobile redirect to recognize the Palm Pre as a mobile device, so I added "|pre"
I hate calling this a bug, more of a feature request,
To here (approx line 505):
case (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|pda|psp|treo)/i',$user_agent)); // check if any of the values listed create a match on the user agent - these are some of the most common terms used in agents to identify them as being mobile devices - the i at the end makes it case insensitive
So it looks like:
case (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|pda|psp|treo|pre)/i',$user_agent)); // check if any of the values listed create a match on the user agent - these are some of the most common terms used in agents to identify them as being mobile devices - the i at the end makes it case insensitive
Seems to work just fine - I made a quick patch, but I seem to suck at patching - so check it out and see what you get! Let me know how I can do it better, patching is not my strong suit.
Thanks!
| Comment | File | Size | Author |
|---|---|---|---|
| mobile_tools_with_pre.patch | 1.72 KB | kirikintha |
Comments
Comment #1
twom commentedThx for the update. Ill apply the patch.
In meantime, I highly recommend looking at the WURFL module (http://drupal.org/projects/wurfl)
This is a much more high quality device detection system.
Regards,
Tom
Comment #2
kirikintha commentedSweet, thanks so much for the clarification
-k
Comment #3
kirikintha commentedI also wanted to make one more not about mobile detection - I modified this approach for a generic mobile detection script that covered some more of the obscure mobile devices, like some of the Palm OS that slipped through, or the Evo which seemed to not detect. I've tried this on Windows, Mac, Linux, with the popular mobile browsers (stock and boutique) and it seems to be a more stable at redirecting to the mobile url when it is really a mobile user agent. Or at least the client hasn't complained about this script... yet, lol.
Just to note: WURFL is pretty great, but I didn't need such focused detection on this project, but I do plan on using it in the future. Thanks for all the hard work on you module!
Comment #4
twom commentedHi,
Thanks for the code. Actually Mobile Tools allows you to create your contrib module to do the device detection.
You just have to implement the following hooks:
hook_is_mobile_device() {
// returns an associative array:
return array(
'type' => 'mobile' or 'desktop',
'group' => [you own defined group]
);
}
hook_device_groups() {
//return an array with device groups your contrib module supports
}
Hope this helps
Comment #6
ealtman commentedThis was a great note, but we discovered that the "pre" addition was inadvertently redirecting Opera desktop browsers because of the "Presto" string in the Opera user agent info.
Added yet another "case" directly under the test for the opera mini:
I need to update to the latest dev version, so forgive me if I've missed something.
Comment #7
ianchan commentedsubscribe
Comment #8
akosipax commentedthis can be fixed by using the browscap module for device detection.