Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons

Reply
 
Thread Tools
VB4 - Mobile Phone / iPhone / PDA Detection and Style Assignment Details »»
VB4 - Mobile Phone / iPhone / PDA Detection and Style Assignment
Version: 1.0.1, by dartho dartho is offline
Developer Last Online: Oct 2023 Show Printable Version Email this Page

Category: Add-On Releases - Version: 4.0.6 Rating:
Released: 09-04-2010 Last Update: 09-06-2010 Installs: 323
Uses Plugins
Re-useable Code  
No support by the author.

This is a direct port from my 3.x versions which detects most mobile phones, iPhones, PDAs and other mobile browsing devices and automatically presents the user with a specific vBulletin style.

The one significant addition over previous versions is that a user can now over-ride the style assignment - more information in the notes section.

This will probably work with previous versions of vBulletin (but untested)

What can it do?Detects most mobile phones and presents the user with a specific style. If you have multiple styles installed which are optimized for small screen mobile devices, iPhones, WIndows Mobile devices you can assign a specific style to each of these groups.

Whilst designed with mobile device users in mind, you could also assign styles to self defined browsers. For example you can assign an alternative style to Internet Explorer users whilst Firefox users get the default style. You could also assign an alternative style to Google or Yahoo spiders.

Instructions:
0. Install styles which you wish to assign to Mobile/PDA/iPhone users
0.5 Uninstall previous versions
1. Download the product file
2. Install via Product Manager
3. Configure options via vBulletin Options, Mobile Device Detection (should appear at end)
4. Start browsing from your mobile device!
5. Click "Mark as Installed"

If upgrading from a previous 3.5, 3.6 or 3.7 version, you will need to uninstall that and the install this one.

To uninstall simply uninstall the product - there are no database changes or additional files.

See HERE for a lightweight vBulletin 4 style to go along with this addon

Version Control
1.0.0 - Initial Release
1.0.1 - Add option to enable/disable overriding style assignment.

Notes
Previous versions of this mod have forced a mobile device to a specific style, this is no longer the case! If a user now follows a link which changes the style (using a URL parameter of "styleid=xx") they will then be given that style for the rest of their session. If they close their browser and reload your site, they will then be detected again. Cookies must be enabled on the users browser for overriding detection to work

To Do
  • Add an option for users to be able to permanently NOT be detected as a mobile device or explicitly use a specified style.
  • Add more devices to detection
  • [S]Add option to disable override globally[/S]

Download Now

File Type: xml product-mobdetect40.xml (11.9 KB, 247 views)
File Type: xml product-mobdetect40.1.0.1.xml (12.9 KB, 1635 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
2 благодарности(ей) от:
asepdoank12, mapleleaffans

Comments
  #82  
Old 02-25-2011, 11:41 AM
siriuxs siriuxs is offline
 
Join Date: Nov 2005
Location: Italia
Posts: 152
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi, I have a problem (excuse me for bad english...)... I have installed this plugin and relative style... If I go on my forum.hdblog.it from my iphone i visualized the desktop template... If i login in the forum is visualized correctly the mobile version... why is visualized the desktop version if I not logged in?

Thanks
Reply With Quote
  #83  
Old 02-26-2011, 02:42 PM
kether1 kether1 is offline
 
Join Date: Jun 2006
Posts: 232
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I would like this to work for iPod and iPhone, but I do not want the iPad to automacally go to the mobile site. If I put iPad in the box at the bottom of this modification, will that solve that issue? I don't own an iPad, but a user emailed and said that s/he really hates that my site assigns the mobile style to the iPad when it used to be the regular PC version with more features.

Thanks for this!
Kether
Reply With Quote
  #84  
Old 02-26-2011, 10:59 PM
dartho dartho is offline
 
Join Date: Sep 2005
Location: Australia
Posts: 2,303
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kether1 View Post
If I put iPad in the box at the bottom of this modification, will that solve that issue?
I don't own any "i" devices to test, but I believe it should ...
Reply With Quote
  #85  
Old 02-28-2011, 08:04 PM
kether1 kether1 is offline
 
Join Date: Jun 2006
Posts: 232
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dartho View Post
I don't own any "i" devices to test, but I believe it should ...
Thank you!
Reply With Quote
  #86  
Old 03-07-2011, 02:21 AM
WinnipegHeights's Avatar
WinnipegHeights WinnipegHeights is offline
 
Join Date: Mar 2005
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Any ETA on an update for this to work with 4.1+?
Reply With Quote
  #87  
Old 03-07-2011, 03:58 PM
bigrover bigrover is offline
 
Join Date: Jun 2010
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have also tried this on my vB 4.1.2 pre-release site and it doesn't auto-detect any longer on my Blackberry 6 OS. It works great on vB 4.0.8. I suspect part of the problem is the built-in browser detection in vB4.1.2 for the new Mobile style. I suspect it is over-riding this hack.

I tried the new Mobile style that is released with vB 4.1.2 but ran into problems. Apparently it does not play well with mods and hacks. In my case, it shows up on the mobile device or the desktop fine, but I cannot navigate to any forums because the links are not working. I can navigate to the options and other settings, but not within the forums themselves. It looks like I will have to abandon mobile style detection for my site if I choose to upgrade to vB 4.1.2 to resolve other security and database searching issues.
Reply With Quote
  #88  
Old 03-29-2011, 06:43 PM
McCarron McCarron is offline
 
Join Date: Apr 2006
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Newly installed and having a slight problem with only Android devices, which was mentioned earlier in the forum, but never resolved. The device I use for testing runs Froyo.

Basically after the first page visit you get the mobile style but then all secondary pages get set to the default style. The only way to prevent that is to enable your new "Enable Over-riding of Styles" option. That's nice that it fixes the other issue but that option prevents users from switching to the Desktop version.

So it fixes a bug but removes a feature from the plugin to allow users to use the regular view.

Any thoughts or ideas?
Reply With Quote
  #89  
Old 03-29-2011, 09:17 PM
dartho dartho is offline
 
Join Date: Sep 2005
Location: Australia
Posts: 2,303
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is working as it is meant to on my site from my phone.

Now that vBulletin has built in mobile device detection, you should probably use that over this if you wish to allow overriding of the mobile detection, they also have to support you if/when you run into issues.
Reply With Quote
  #90  
Old 03-30-2011, 07:56 PM
McCarron McCarron is offline
 
Join Date: Apr 2006
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dartho View Post
This is working as it is meant to on my site from my phone.

Now that vBulletin has built in mobile device detection, you should probably use that over this if you wish to allow overriding of the mobile detection, they also have to support you if/when you run into issues.
I'm sorry I thought this plugin was still supported? It says so right at the top of the page. You may want to change that if you are no longer providing support in lieu vBulletin's new feature. I would happily use vBulletin's implementation if I was on their latest version, but I am not and don't have plans to move at this time.

Well anyone else interested, this plugin has a glitch when certain Android devices visit. Here is how you can fix it to work for them:

You have to Disable the Enable Over-riding of Styles option. Mobile Users now will be forced into the mobile theme, but wont be able to switch to the regular site anymore. SO if you are also using dartho's Lightweight Style and Options theme/plugin system you need to disable the Add a link to the default style? option in Lightweight Style Options as the user will not be able to switch styles anymore.

It's a bad experience for all mobile users to be forced into the mobile theme, but it's the only way I could get this plugin to work for the various types of users navigating to our site.

Also here are some additional useragents I check for that allow Android and HP/Palm webOS phones to be detected properly. It also detects the iPhone Simulator so those of you with the iPhone SDK can test the iPhone layout easily on your Mac.

Quote:
WebOS,webOS,Simulator,Android
I also have excluded "iPad" from the exclusions list because the iPad doesn't need a mobile theme as it's screen is plenty large, but it automatically gets lumped into the iPhone devices by default.
Reply With Quote
  #91  
Old 03-30-2011, 11:53 PM
dartho dartho is offline
 
Join Date: Sep 2005
Location: Australia
Posts: 2,303
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I didnt say I wasn't supporting it, I just made a suggestion. My next (based on you not using version 4.1.2) would be to download version 4.1.2 and take their detection code out and put it in a plugin to test if it is effective on your device.

I've done this for you.
Edit the Detect Mobile Device and Assign Style plugin
Comment out the existing code (by putting a /* at the very start, and a */ at the very end of it)
Paste in the following code at the start
PHP Code:
$vbulletin->input->clean_array_gpc('c', array(
    
COOKIE_PREFIX 'userstyleid'     => TYPE_UINT,
    
COOKIE_PREFIX 'skipmobilestyle' => TYPE_BOOL,
));

// Test mobile browser
$mobile_browser false;
$mobile_browser_advanced false;
if (
$vbulletin->options['mob_detect_enabled'])
{
    if (
stripos($_SERVER['HTTP_USER_AGENT'], 'windows') === false)
    {
        if (
            
preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android)/i'strtolower($_SERVER['HTTP_USER_AGENT']))
            OR
            
stripos($_SERVER['HTTP_ACCEPT'],'application/vnd.wap.xhtml+xml') !== false
            
OR
            ((isset(
$_SERVER['HTTP_X_WAP_PROFILE']) OR isset($_SERVER['HTTP_PROFILE'])))
            OR
            
stripos($_SERVER['ALL_HTTP'],'OperaMini') !== false
        
)
        {
            
$mobile_browser true;
        }
        
// This array is big and may be bigger later on. So we move it to a second if.
        
elseif (in_array(
                    
strtolower(substr($_SERVER['HTTP_USER_AGENT'], 04)),
                    array(
                    
'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
                    
'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
                    
'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
                    
'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
                    
'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
                    
'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
                    
'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
                    
'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
                    
'wapr','webc','winw','winw','xda ','xda-')
                )
            )
        {
            
$mobile_browser true;
        }
    }

    if (
        
$mobile_browser
        
AND
        
preg_match('/(ipad|ipod|iphone|blackberry|android|pre\/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)/i'strtolower($_SERVER['HTTP_USER_AGENT']))
    )
    {
        
$mobile_browser_advanced true;
    }
}
$vbulletin->input->clean_array_gpc('r', array(
    
'styleid' => TYPE_INT,
    
'langid'  => TYPE_INT,
));


// Set up user's chosen style
if ($vbulletin->GPC['styleid'])
{
    
$styleid =& $vbulletin->GPC['styleid'];
    
vbsetcookie('userstyleid'$styleid);
    if (
$styleid == -1)
    {
        
vbsetcookie('skipmobilestyle'1);
        
$vbulletin->GPC[COOKIE_PREFIX 'skipmobilestyle'] = 1;
    }
    elseif (
$styleid == $vbulletin->options['ipod_skin_enabled'] OR $styleid == $vbulletin->options['mobile_skin_enabled'])
    {
        
vbsetcookie('skipmobilestyle'0);
        
$vbulletin->GPC[COOKIE_PREFIX 'skipmobilestyle'] = 0;
    }
}
elseif (
$mobile_browser_advanced && $vbulletin->options['ipod_skin_enabled'] && !$vbulletin->GPC[COOKIE_PREFIX 'skipmobilestyle'])
{
    
$styleid $vbulletin->options['ipod_skin'];
}
elseif (
$mobile_browser && $vbulletin->options['mobile_skin_enabled'] && !$vbulletin->GPC[COOKIE_PREFIX 'skipmobilestyle'])
{
    
$styleid $vbulletin->options['mobile_skin'];
}
elseif (
$vbulletin->GPC[COOKIE_PREFIX 'userstyleid'])
{
    
$styleid $vbulletin->GPC[COOKIE_PREFIX 'userstyleid'];
}
else
{
    
$styleid 0;

Save

Whilst this is vBulletin's code (although it is near identical to code readily available 'out there' for mobile detection), I modified it ever so slightly to use the options from my add-on for Mobile Style and iPod Style - so enable detection of these and configure which style to disaply accordingly. When using this code, other options (such as override (which is on by default with teh above code), custom agents, etc ) are ignored.

Test and let us know how it goes. Don't try this if you're on vb4.1.2 or higher, it's already there. This is just put here as a test and is incomplete.
Reply With Quote
Reply

Thread Tools

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 10:41 AM.


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.04882 seconds
  • Memory Usage 2,400KB
  • Queries Executed 28 (?)
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
  • (1)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
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (2)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
  • (2)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_postinfo_query
  • fetch_postinfo
  • 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