vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   Integration with vBulletin - Mobile Device & Browser Detection (Adapted by BOP5) (https://vborg.vbsupport.ru/showthread.php?t=292704)

BirdOPrey5 12-05-2012 11:00 PM

Mobile Device & Browser Detection (Adapted by BOP5)
 
1 Attachment(s)
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 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.

Code:

$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:

PHP Code:

if ($vbulletin->detect->isMobile())
  
$vbulletin->options['isMobile'] = 1

Then in a template you can use...

Code:

<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:
Code:

if ($vbulletin->detect->isMobile())
  $vbulletin->options['isMobile'] = 1;


BirdOPrey5 03-03-2013 12:07 PM

Templates use template conditionals...

You can try:

Code:

<vb:if condition="$vbulletin->detect->isMobile()">
Use this HTML code if mobile
</vb:if>

or

Code:

<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:

Code:

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

Quote:

Originally Posted by ivanp (Post 2409190)
Nice mod :)

I suggest changing the hook to "init_startup" to be able to replace default mobile browser detection in init.php with:

Code:

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??

Code:

$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

Quote:

Originally Posted by Toorak Times (Post 2426822)
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:

PHP Code:

<vb:if condition="!$vboptions['isMobile']">

code code code

</vb:if> 


BirdOPrey5 08-17-2013 10:41 AM

Quote:

Originally Posted by Okuma Steve (Post 2439129)
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:

PHP Code:

<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

Quote:

Originally Posted by oldfan (Post 2486626)
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

Quote:

Originally Posted by ivanp (Post 2409190)
Nice mod :)

I suggest changing the hook to "init_startup" to be able to replace default mobile browser detection in init.php with:

Code:

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

Quote:

Originally Posted by oldfan (Post 2486626)
This work with 4.2.2? Cause I installed it and I still get the regular site with my iphone.

Quote:

Originally Posted by Actualidad TMA (Post 2522952)
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

Quote:

Originally Posted by BirdOPrey5 (Post 2523016)
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

Quote:

Originally Posted by Big-K (Post 2542682)
To earlier question, how do you use this to change styles?

Create a plugin on the style_fetch hook...

Code would be:

PHP Code:

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-


PHP Code:

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

Code:

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
Code:

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

Quote:

Originally Posted by ruchemist (Post 2563258)
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

Quote:

Originally Posted by BirdOPrey5 (Post 2407577)
Templates use template conditionals...

You can try:

Code:

<vb:if condition="$vbulletin->detect->isMobile()">
Use this HTML code if mobile
</vb:if>

or

Code:

<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.

iA1 09-08-2018 07:10 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2581436)
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.


All times are GMT. The time now is 03:23 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01352 seconds
  • Memory Usage 1,845KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (13)bbcode_code_printable
  • (5)bbcode_php_printable
  • (12)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete