Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Mobile Device & Browser Detection (Adapted by BOP5) Details »»
Mobile Device & Browser Detection (Adapted by BOP5)
Version: 1.00, by BirdOPrey5 (Senior Member) BirdOPrey5 is offline
Developer Last Online: Aug 2023 Show Printable Version Email this Page

Category: Integration with vBulletin - Version: 4.x.x Rating:
Released: 12-05-2012 Last Update: Never Installs: 60
Uses Plugins
Re-useable Code Additional Files  
No support by the author.

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!

Download Now

File Type: zip Mobile Browser Detect v1.zip (13.9 KB, 402 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Благодарность от:
RichieBoy67

Comments
  #32  
Old 04-09-2015, 11:13 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Big-K View Post
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.
Reply With Quote
  #33  
Old 06-22-2015, 08:16 AM
induslady induslady is offline
 
Join Date: Jul 2006
Posts: 224
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #34  
Old 06-23-2015, 03:35 AM
induslady induslady is offline
 
Join Date: Jul 2006
Posts: 224
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello all,

Any help is appreciated. Am looking to nail the issue. Thanks.
Reply With Quote
  #35  
Old 08-16-2015, 02:29 AM
m2006's Avatar
m2006 m2006 is offline
 
Join Date: Jan 2006
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Not support Search Engine Friendly Archive on vbulletin 4.2.3

you test
Code:
http://www.siteforyou.com/forum/archive/index.php
Reply With Quote
  #36  
Old 01-23-2016, 08:19 AM
ruchemist ruchemist is offline
 
Join Date: Jul 2009
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

User cannot change style if it is detected as mobile device?
Reply With Quote
  #37  
Old 01-23-2016, 09:09 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ruchemist View Post
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.
Reply With Quote
  #38  
Old 01-27-2017, 09:24 AM
boffin_adi boffin_adi is offline
 
Join Date: Dec 2010
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
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
Reply With Quote
  #39  
Old 01-27-2017, 11:01 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What template are you trying? This is very old anyway, not sure how useful it is anymore.
Reply With Quote
  #40  
Old 06-06-2017, 11:37 AM
flox80 flox80 is offline
 
Join Date: Mar 2017
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #41  
Old 09-08-2018, 07:10 PM
iA1 iA1 is offline
 
Join Date: Jul 2018
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:57 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.19152 seconds
  • Memory Usage 2,348KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (5)bbcode_code
  • (2)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete