• Welcome to Simple Machines Community Forum. Please login or sign up.

Question about use of $context['browser'] for mobile devices

Started by Gwenwyfar, February 11, 2015, 01:57:35 PM

Previous topic - Next topic


I was looking at the array list on $context to find some I needed, and I thought of some uses for some others as well. One of them would be to use the browser related ones ([is_android], [is_iphone]) to remove certain things (specially images) from loading completely on mobile devices instead of just blocking them with css, to eat less of the already poor download speed on them.

But it seems to be very device-specific (and have in mind I know absolutely nothing about what kind of device is what, to me they're all either a phone or a tablet computer), so I wanted to know if there is any combination of them that I can use to target ANY mobile device? Or will just those target most of them already? On any case I will keep the CSS block for those that might not get affected, but it would be useful to know on which ones it works, exactly, or how does it define what is what.


Nope. You can write your own array to target any you want to hit, but the default 2.0.x array is very limited. It basically covers iphone and (generic) android and not much else. To cover every mobile device is use anywhere in the world, you'd have to make quite a few additions.

I did write a mod which extended it somewhat, and IIRC there was an even more comprehensive one written by someone else (maybe Emanuele).


Didn't know there was a mod for it, I'll give it a try, thanks :)

His mod seems to be for making a separate theme though, I'll see if I can use just the detection from it.


Oh. That is a woman's name around here, because of the "e" after "l"  :P I'll remember that next time ;)


Ahh. His name is pretty common here too, but its "Emanuel" instead :P


Quote from: Fortytwo on February 11, 2015, 04:23:52 PM
His mod seems to be for making a separate theme though, I'll see if I can use just the detection from it.
Nope, I think it is not ;)

QuoteOnce instantiated the class is placed in $context['device'], so that other mods and themes can use the it in order to do change their behaviour depending on the device.
This means (to me) that you can not choose any dedicated mobile theme and *still* have $context['device'] show you the proper info ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair


Ah, I think I missed that part. Was talking about this one:
QuoteAt the moment in this mod this function is used to allow admins to select a default theme for mobile devices.