I added a rule in the chain for browscap:ismobiledevice = true, but it doesn't trigger. I have the most recent version of browscap installed (see below) and the most recent version of Themekey (I tried both alpha2 and dev).
I enabled Themekey Debug and this is what I see:
No match: "browscap:ismobiledevice = true >>> default"
However further down the page I see:
browscap:ismobiledevice
1
If I click on the "1" to create a new rule I get this error when saving:
Possible values are "true" and "false"
So it seems like the 1 isn't being treated as "true"?
Using:
Drupal 7.23
Browscap 7.x-2.0+3-dev (2013-Oct-14)
ThemeKey 7.x-3.0-alpha2+1-dev (2013-Oct-22)
Comments
Comment #1
mkalkbrennerComment #2
mkalkbrenner@jlea9378: I verified ThemeKey 7.x-3.x-dev again in combination with Browscap 2.0 and 2.x-dev. The value of browscap:ismobiledevice is always one of the strings "true" or "false" and never "1" or "0".
Also the switching based on browscap:ismobiledevice works!
The only thing I can think of is that browscap itself contains a bug. Maybe it returns different values depending on the user agent.
@jlea9378: Can you please post the value of browscap:useragent when browscap:ismobiledevice is "1"
Comment #3
jlea9378 CreditAttribution: jlea9378 commentedok so I am using:
Browscap 7.x-2.0+3-dev (2013-Oct-14) (I see there is a new 2.1 release but I haven't upgraded yet)
7.x-3.0-alpha2+1-dev (2013-Oct-22) (also there's a new TK dev but I haven't upgraded yet)
Using TK Debug-
On my iPad:
browscap:ismobiledevice
1
Browscap:useragent
mozilla/5.0 (ipad; cpu os 7_0_2 like mac os x) applewebkit/537.51.1 (khtml, like gecko) version/7.0 mobile/11a501 safari/9537.53
On my droid using default browser:
browscap:ismobiledevice
1
Browscap:useragent
Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; MB886 Build/9.8.0Q-97_MB886_FFW-20) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
On droid in Chrome browser:
browscap:ismobiledevice
1
Browscap:useragent
Mozilla/5.0 (Linux; Android 4.1.1; MB886 Build/9.8.0Q-97_MB886_FFW-20) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.92 Mobile Safari/537.36
On droid in Firefox browser:
browscap:ismobiledevice
1
Browscap:useragent
Mozilla/5.0 (Android; Mobile; rv:24.0) Gecko/24.0 Firefox/24.0
As you can see, TK Debug always shows a value of "1" for Browscap:ismobiledevice for me on my devices on the site. If logged in and I click the "1", it actually creates a rule and populates the value with the 1. But it doesn't let me save it that way, and creating a rule with "true" doesn't function (the theme never switches).
Comment #4
mkalkbrennerThanks for these details. I'll do some more testing ....
Comment #5
gianfrasoft CreditAttribution: gianfrasoft commentedSame problem here and I solved this way:
file: themekey\modules\themekey.browscap.inc
row: 67
change validator: themekey_validator_string_boolean
with validator: themekey_validator_nummeric_boolean
here is the code:
After this change you can use value "1" in ismobiledevice rule.
Hope will help!
Bye.
-- EDIT --
It seems the validator's function name "themekey_validator_nummeric_boolean" that was mispelled (_num
meric_) have been changed. So my patch has become:file: themekey\modules\themekey.browscap.inc
row: 67
change validator: themekey_validator_string_boolean
with validator: themekey_validator_numeric_boolean
here is the code:
Comment #6
gianfrasoft CreditAttribution: gianfrasoft commentedComment #7
jlea9378 CreditAttribution: jlea9378 commentedThanks that change worked!
Question: Why is 'numeric' misspelled in that function name?
Comment #8
mkalkbrenner@gianfrasoft: can you provide some more details like browscap and php version?
Comment #9
gianfrasoft CreditAttribution: gianfrasoft commentedThe mispelled "numeric" word is a mispelled name of a function decleared this way... I had to call the function using it's mispelled name.
Comment #10
gianfrasoft CreditAttribution: gianfrasoft commented@mkalkbrenner here are my server infos:
- Apache/2.2.14 (Unix)
- MySql 5.1.63-enterprise-commercial-advanced-log
- PHP 5.4.4-14+deb7u2 (ulteriori informazioni)
- Memory limit: 140M
browscap has been updated online - see http://browscap.org/
Bye.
Comment #11
mkalkbrennerIf you have a look at php_browscap.ini at http://browscap.org/ you'll see that the values for isMobileDevice are the strings 'true' or 'false'. And I see these values passed to ThemeKey.
But obviously these values change to integers in some setups. I have no idea why but I think the right fix will be to deal with both scenarios by converting integers back to strings if they occur.
I committed such a solution. Can you test the latest version from git?
Comment #12
gianfrasoft CreditAttribution: gianfrasoft commentedSorry, I can't... my project is online on a production server so... it would be too much dangerous for me.
Maybe @jlea9378 should...
Comment #13
jlea9378 CreditAttribution: jlea9378 commentedI downloaded the latest Browscap module and pulled Themekey from git, so I have:
Browscap 7.x-2.1
Current browscap data version: 5020.
Themekey 7.x-3.0-rc1 (in the changelog)
I enabled TK Debug and loaded my site on my iPad and it shows "true" now for ismobiledevice. My rule chain excludes iPad's, so it correctly got the full theme.
My Android phone also shows "true" in the default browser (whatever that is) and Chrome. However for some crazy reason my phone shows "false" in Firefox 25. Themekey successfully switches the theme in the default browser and Chrome as per the rule in my chain for "ismobiledevice:true". But it doesn't in Firefox.
Here's the user agent for Android Firefox 25:
Mozilla/5.0 (Android; Mobile; rv:25.0) Gecko/25.0 Firefox/25.0
Any idea why it translated to "false" but other browsers translated to "true" on my droid?
Comment #14
jlea9378 CreditAttribution: jlea9378 commentedComment #15
mkalkbrennerThat's not ThemeKey's fault. You have to report that in the browscap issue queue.
Comment #16
jlea9378 CreditAttribution: jlea9378 commentedI'm a little confused since the Browscap module page says unrecognized UA's should be reported on the Browscap github project and I went there and there is already an issue regarding Firefox 25, but it indicates it's fixed in the latest version 5021-b7 (2nd Nov 2013). However the Browscap module's admin UI says 5020 is the most recent version. I guess it doesn't pull beta releases, if that's what the "b7" stands for.
Anyways, it looks like it will be resolved soon once the module gets 5021...