The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Display images based on browser
Alright...I am working on a bit of code for my forum style and this is the general premis.
In my postbit legacy, I give my users the ability to display their PSN and XBL gamercards. Now...this causes a bit of lag with mobile browsers so I want the ability to not show certain images or certain things for mobile browsers to improve load times. I have a bit of code in mind to do this but I am having difficulty with it. In my style template, I have something like this: <if condition="$_SERVER['HTTP_USER_AGENT'] == SOMETHING"> DO STUFF </if> that SOMETHING is supposed to be, say for example, the mobile safari user agent. I could turn that something into 'iPhone' but I would need an equivalent to a contains comparison as opposed to an ==.does anyone know the comparator for "contains"? I want to change the == to something that represents "contains" or "string contains" |
#2
|
|||
|
|||
Looking at the list of allowed functions in the vBulletin manual, I don't think there's a "string contains" function you can call from a template conditional, so you'd have to do that in a plugin somewhere. There is a function called "is_browser" you can call to check the browser, but it only recongnizes a certain set of browsers and iPhone isn't one of them. (The list seems to be "opera, ie, mozilla, firebird, firefox, camino, konqueror, safari, webkit, webtv, netscape, mac").
So, you could probably just use the "global_start" and set an "is_mobile" variable or something. I'll bet if you searched the web (or maybe the mods here) you can find code for checking the browser string so that you don't have to figure all that out. |
#3
|
||||
|
||||
The 'right' way to do this is to just make a new or child style of your current style that is optimized for mobile browsers and have your mobile users use that.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|