View Full Version : Integration with vBulletin - Mobile Device & Browser Detection (Adapted by BOP5)
BirdOPrey5
12-05-2012, 11:00 PM
This mod has no settings or options.
Installed alone and you will see nothing new.
The purpose of this mod is to bring a reliable way of detecting mobile browsers and devices to vBulletin for use in other mods.
Currently the only mod I know it is recommended for is my Sidebar Anywhere (https://vborg.vbsupport.ru/showthread.php?t=283307) mod.
The bulk of the work of this mod is done by a publicly available PHP Mobile Detection class from:
http://code.google.com/p/php-mobile-detect/
The file name was changed to prevent conflicts but the file contents including license information remains unchanged.
Once installed the mod will allow you to use $vbulletin->detect to detect various mobile options anywhere $vbulletin variable is available in the code.
Its plugin load priority is set to 1 so it executes before all other plugins.
$vbulletin->options['bop5_mob_detect'] = true; //True if mod enabled/installed
$vbulletin->detect->isMobile() - true if any mobile device
$vbulletin->detect->isTablet() - true if tablet
$vbulletin->detect->isiOS() - true if any iOS device
$vbulletin->detect->isAndroidOS() - true if any Android
------------------------------------------------------
Please "Mark as Installed" if you use this. :)
Donations always appreciated. :up:
Nominate MOTM if you LOVE it! ;)
BirdOPrey5
12-06-2012, 01:04 AM
List of Compatible Mods:
(Will edit if more get added by any coder)
Sidebar Anywhere - https://vborg.vbsupport.ru/showthread.php?t=283307
RedTurtle
12-06-2012, 11:03 PM
Thank you so much for this mod! Needed this today and just came on VBorg and found this was just recently released.
Worked perfectly! :D
Edit: What do you recommend as to the best way to use these options in a template?
BirdOPrey5
12-07-2012, 02:04 AM
The easiest way to implement this in a template would be to edit the plugin for this mod...
At the bottom add lines such as:
if ($vbulletin->detect->isMobile())
$vbulletin->options['isMobile'] = 1;
Then in a template you can use...
<vb:if condition="$vboptions['isMobile']">xxxx</vb:if>
v123shine
12-07-2012, 05:33 AM
Nice mod. Thanks
acast
01-12-2013, 01:01 PM
Anybody knows if this plugin works for the mobile quotes? They don't appear in notifications.
BirdOPrey5
01-12-2013, 01:53 PM
I'm not sure what "mobile quotes" are so I doubt it. The only mod it works with I know of is my Sidebar Anywhere.
sinomama
01-15-2013, 10:09 AM
It doesn't work for 3.8.5. What a pity. :(
bartek24m
02-21-2013, 06:13 PM
How to implement it in "footer" template ?
Where do i need paste it:
if ($vbulletin->detect->isMobile())
$vbulletin->options['isMobile'] = 1;
BirdOPrey5
03-03-2013, 12:07 PM
Templates use template conditionals...
You can try:
<vb:if condition="$vbulletin->detect->isMobile()">
Use this HTML code if mobile
</vb:if>
or
<vb:if condition="$vbulletin->detect->isMobile()">
Use this HTML code if mobile
<vb:else />
Use this code if NOT mobile
</vb:if>
karabaja3
03-06-2013, 12:01 AM
Will this work on v3.8.7?
Becuase this one doesn't https://vborg.vbsupport.ru/showthread.php?t=173239
BirdOPrey5
03-09-2013, 09:42 AM
Only for 4.x, sorry.
ivanp
03-10-2013, 05:53 PM
Nice mod :)
I suggest changing the hook to "init_startup" to be able to replace default mobile browser detection in init.php with:
if($vbulletin->options['bop5_mob_detect'])
{
$mobile_browser = $vbulletin->detect->isMobile();
if($mobile_browser && $vbulletin->detect->isTablet()) $mobile_browser = false;
$mobile_browser_advanced = $mobile_browser;
}
That way tablets will not be considered as mobile devices, thus not being served mobile style as default style.
Budget101
06-09-2013, 11:25 AM
Nice mod :)
I suggest changing the hook to "init_startup" to be able to replace default mobile browser detection in init.php with:
if($vbulletin->options['bop5_mob_detect'])
{
$mobile_browser = $vbulletin->detect->isMobile();
if($mobile_browser && $vbulletin->detect->isTablet()) $mobile_browser = false;
$mobile_browser_advanced = $mobile_browser;
}
That way tablets will not be considered as mobile devices, thus not being served mobile style as default style.
wouldn't removing the following line do the same thing??
$vbulletin->detect->isTablet() - true if tablet
Toorak Times
06-09-2013, 11:34 AM
Hey BOP, does this make our videos and stuff work on iPhones and pads?
BirdOPrey5
06-09-2013, 03:24 PM
Hey BOP, does this make our videos and stuff work on iPhones and pads?
No- it merely detects if it is a mobile browser or not- it does nothing without custom coding.
However to have YouTube and other videos work on iPhones and stuff check out these HTML 5 changes- https://vborg.vbsupport.ru/showthread.php?t=283594
behcet
07-31-2013, 06:57 PM
upgrade pls
datoneer
07-31-2013, 09:45 PM
Thanks, installed, nominated
Okuma Steve
08-16-2013, 06:38 AM
Just installed this on my site and it is treating all my devices as desktop browsers and not mobile. Any ideas on why that may be?
I've tested it with a nexus 4, nexus 7, and an Ipad 1
I'm using this to hide a footer ad from mobile users:
<vb:if condition="!$vboptions['isMobile']">
code code code
</vb:if>
BirdOPrey5
08-17-2013, 10:41 AM
Just installed this on my site and it is treating all my devices as desktop browsers and not mobile. Any ideas on why that may be?
I've tested it with a nexus 4, nexus 7, and an Ipad 1
I'm using this to hide a footer ad from mobile users:
<vb:if condition="!$vboptions['isMobile']">
code code code
</vb:if>
Did you follow the instructions in post #4? $vboptions['isMobile'] isn't going to exist if you don't set the value via a plugin first.
oldfan
03-12-2014, 05:40 AM
This work with 4.2.2? Cause I installed it and I still get the regular site with my iphone.
Guest20210129
11-16-2014, 10:51 AM
This work with 4.2.2? Cause I installed it and I still get the regular site with my iphone.
Same for me.
Guest20210129
11-16-2014, 11:02 AM
Nice mod :)
I suggest changing the hook to "init_startup" to be able to replace default mobile browser detection in init.php with:
if($vbulletin->options['bop5_mob_detect'])
{
$mobile_browser = $vbulletin->detect->isMobile();
if($mobile_browser && $vbulletin->detect->isTablet()) $mobile_browser = false;
$mobile_browser_advanced = $mobile_browser;
}
That way tablets will not be considered as mobile devices, thus not being served mobile style as default style.
Can you explain how to implement this? Which files i have to modify?
Thanks.
BirdOPrey5
11-16-2014, 07:23 PM
This work with 4.2.2? Cause I installed it and I still get the regular site with my iphone.
Same for me.
Installing this doesn't change any styles. It is for use in your own custom coding.
oldfan
11-25-2014, 07:50 PM
Installing this doesn't change any styles. It is for use in your own custom coding.
Can it be used for changing styles?
tme_power
11-27-2014, 08:49 PM
Very nice mod indeed! Thanks.
Morrus
12-07-2014, 11:32 AM
One potential use I can see for this is controlling the number of columns shown on the CMS page when viewed on a mobile device as set in the Content Columns dropdown in the Section Information section of the (frontend) Section editor. Certainly for my site, it look much better as one column on a mobile device, but better as two columns on a desktop computer.
Is there an easy way to use this plugin to conditionify whatever bit of code sets the number of columns?
iyihost
12-16-2014, 08:02 PM
vbulletin 3.8 ?
Mathsman
02-28-2015, 10:26 PM
With this plugin can assign users how mobile themes?
Big-K
04-09-2015, 10:52 AM
To earlier question, how do you use this to change styles?
BirdOPrey5
04-09-2015, 11:13 AM
To earlier question, how do you use this to change styles?
Create a plugin on the style_fetch hook...
Code would be:
global $vbulletin;
$mobilestyle = 38; //Set this to the id of your mobile style
if($vbulletin->detect->isMobile())
{
$styleid = $mobilestyle;
$_REQUEST['styleid'] = $mobilestyle;
$vbulletin->GPC['styleid'] = $mobilestyle;
}
That is a bare bones plugin. It will change to the mobile style if a mobile device is detected. The problem is that no one could ever change back to the regular style on a mobile device. You probably want to add some code to deal with that.
For example if you are doing this to appease Google then maybe you only want to make this plugin active if it's a guest viewing the site, and not a registered member. In that case add a check to the conditional-
global $vbulletin;
$mobilestyle = 38; //Set this to the id of your mobile style
if($vbulletin->detect->isMobile() AND $vbuletin->userinfo['usergroupid'] == 1)
{
$styleid = $mobilestyle;
$_REQUEST['styleid'] = $mobilestyle;
$vbulletin->GPC['styleid'] = $mobilestyle;
}
usergroupid 1 is the guest usergroup.
If you want to get fancier you can use a cookie or something.
induslady
06-22-2015, 08:16 AM
Hello BOP5,
I have installed this plugin and want to make use it such that for tablets I want to show the users desktop style.
The desktop style id is 16 and I used the below plugin
Product: vbulletin
Hook Location : style_fetch
global $vbulletin;
$tabstyle = 16; //Set this to the id of your mobile style
if($vbulletin->detect->isTablet())
{
$styleid = $tabstyle;
$_REQUEST['styleid'] = $tabstyle;
$vbulletin->GPC['styleid'] = $tabstyle;
}
But it is not working as intended i.e it is showing the mobile style in tablets too.
But I want to show the desktop style in tablets, How do I fix this. Thanks in advance.
induslady
06-23-2015, 03:35 AM
Hello all,
Any help is appreciated. Am looking to nail the issue. Thanks.
m2006
08-16-2015, 02:29 AM
Not support Search Engine Friendly Archive on vbulletin 4.2.3
you test http://www.siteforyou.com/forum/archive/index.php
ruchemist
01-23-2016, 08:19 AM
User cannot change style if it is detected as mobile device?
BirdOPrey5
01-23-2016, 09:09 AM
User cannot change style if it is detected as mobile device?
This mod doesn't force anything, it is only for people writing their own custom code.
boffin_adi
01-27-2017, 09:24 AM
Templates use template conditionals...
You can try:
<vb:if condition="$vbulletin->detect->isMobile()">
Use this HTML code if mobile
</vb:if>
or
<vb:if condition="$vbulletin->detect->isMobile()">
Use this HTML code if mobile
<vb:else />
Use this code if NOT mobile
</vb:if>
This code this not working in templates
BirdOPrey5
01-27-2017, 11:01 PM
What template are you trying? This is very old anyway, not sure how useful it is anymore.
flox80
06-06-2017, 11:37 AM
Hi,
On 4.2.4. , I am trying to use this templates :
<vb:if condition="$vbulletin->detect->isMobile()">
{vb:raw test1}
<vb:else />
{vb:raw test2}
</vb:if>
but it doesn't work.
Any idea why?
Thanks.
What template are you trying? This is very old anyway, not sure how useful it is anymore.
I have managed to create a vB 3 version of this, with additional functionality for responsive styles. If you permit, I will release it as a new mod.
BirdOPrey5
09-10-2018, 01:08 PM
Feel free. I hope there was an update available to the mobile detection library though it's 6 years out of date.
FYI the "Reusable Code" flag at the top of the page means you don't need to ask permission, you are free to reuse the code in any mods you release here on vbulletin.org.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.