This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Install & configuration » Best practise for using...

Best practise for using DetectMobileDevice on some devices only

Best practise for using DetectMobileDevice on some devices only

Monday 05 November 2012 1:42:12 pm - 1 reply

Hi, we're trying to use DetectMobileDevice but without [IPadDevice]=/ipad/i because iPad will use the desktop siteaccess.

If I comment out MobileUserAgentRegexps[IPadDevice]=/ipad/i in an override, the /settings/site.ini will rule. And even if I remove it from /settings/site.ini the iPad client still gets redirected to the mobile siteaccess.

I've also tried to rename the MobileUserAgentRegexps[IPadDevice]=/ipad/i    so for instance site.ini:MobileUserAgentRegexps[IPadDevice]=/NOpad/i

Has anyone experienced something like this?

Thursday 15 November 2012 5:05:02 pm

I think the issue is that the word "Mobile" may be in the user agent string, so even though you've disabled the iPad setting, iPads are being identified as Generic mobile.

Listing 2-5  iPad running iOS 3.2 user agent string

Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10

My recommendation would be to try the following lines in settings/override/site.ini.append.php:

MobileUserAgentRegexps[IPadDevice]=    # (empty string, which should clear the value)
MobileUserAgentRegexps[Generic]=/(!ipad)(mini 9.5|vx1000|lge |m800|e860|u940|ux840|compal|wireless|  mobi|ahong|lg380|lgku|lgu900|lg210|lg47|lg920|lg840|lg370|sam-r|mg50|s55|g83|t66|vx400|mk99|d615|d763|el370|sl900|mp500|samu3|samu4|vx10|xda_|samu5|samu6|samu7|samu9|a615|b832|m881|s920|n210|s700|c-810|_h797|mob-x|sk16d|848b|mowser|s580|r800|471x|v120|rim8|c500foma:|160x|x160|480x|x640|t503|w839|i250|sprint|w398samr810|m5252|c7100|mt126|x225|s5330|s820|htil-g1|fly     v71|s302|-x113|novarra|k610i|-three|8325rc|8352rc|sanyo|vx54|c888|nx250|n120|mtk     |c5588|s710|t880|c5005|i;458x|p404i|s210|c5100|teleca|s940|c500|s590|foma|samsu|vx8|vx9|a1000|_mms|myx|a700|gu1100|bc831|e300|ems100|me701|me702m-three|sd588|s800|8325rc|ac831|mw200|brew     |d88|htc\/|htc_touch|355x|m50|km100|d736|p-9521|telco|sl74|ktouch|m4u\/|me702|8325rc|kddi|phone|lg    |sonyericsson|samsung|240x|x320|vx10|nokia|sony  cmd|motorola|up.browser||mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|psp|treo)/i

The addition of (!ipad) should prevent matches on iPads.

Modified on Thursday 15 November 2012 5:05:36 pm by Betsy Gamrat


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from