PDA

View Full Version : Add-On Releases - VB4 - Mobile Phone / iPhone / PDA Detection and Style Assignment


dartho
09-04-2010, 10:00 PM
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 (https://vborg.vbsupport.ru/showthread.php?t=249277)

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
Add option to disable override globally

dartho
09-05-2010, 12:02 PM
F.a.q.

sulasno
09-05-2010, 01:13 PM
tagged and thanks

sbsforum.us
09-05-2010, 02:19 PM
This is great, I have been waiting for this. Thank you!

reefland
09-05-2010, 07:38 PM
Tagged. Currently using the previous version with no problems.

moonclamp
09-05-2010, 08:01 PM
This version is great 'cos users can switch back to the normal style - so thank you for that :)

However, I have one user who says his Samsung phone is now going to the default style after the welcome page ... but it worked on the previous version - he's deleted his cache/cookies too (so he says).

dartho
09-05-2010, 09:39 PM
so when he first visits, he gets a specified style, but when he clicks a link het gets the default style?

moonclamp
09-05-2010, 09:44 PM
Yeah pretty much.

It's a Samsung phone, so the useragent is there, he reckons he cleared his cookies and rebooted his phone too ... I wish I knew more about his phone.

Most other users are reporting no problems, except one (A nokia user) who is now stuck on the default style (I'm a Nokia user and I have no problems).

dartho
09-05-2010, 09:54 PM
try giving him a link to follow to the style, ie. http://mydomain.com/forum.php?styleid=nn where nn is the style you want to display to him on his phone

moonclamp
09-05-2010, 10:04 PM
try giving him a link to follow to the style, ie. http://mydomain.com/forum.php?styleid=nn where nn is the style you want to display to him on his phone
Cheers, I'll report back :)

djbaxter
09-05-2010, 10:52 PM
Question: How many additional database queries are required by this add-on?

dartho
09-05-2010, 11:29 PM
zero

djbaxter
09-05-2010, 11:37 PM
zero

Great. That's what I thought I was seeing but I wasn't sure how it was possible to determine the device being used without additional queries. :)

CvP
09-06-2010, 01:00 AM
Great. That's what I thought I was seeing but I wasn't sure how it was possible to determine the device being used without additional queries. :)
http://en.wikipedia.org/wiki/User_agent

djbaxter
09-06-2010, 01:17 AM
Oh, of course. Just a simple if... then. :o

Hornstar
09-06-2010, 05:50 AM
Nice update. thanks.

moonclamp
09-06-2010, 08:43 AM
try giving him a link to follow to the style, ie. http://mydomain.com/forum.php?styleid=nn where nn is the style you want to display to him on his phone

Cheers, I'll report back :)Still got the same problem, and it's also being reported on the LG Secret too.

Considering it worked on the older version, I'm thinking the only way to make the style fully switchable (without problems) is with a custom profile option and a conditional to turn off the useragent detection ... I did try the following:

if ($vbulletin->options['mob_detect_enabled'] == 1 AND $bbuserinfo['fieldxx'] == "On")

but that just killed the plugin completely.

dartho
09-06-2010, 09:21 AM
You would be after:
if (($vbulletin->options['mob_detect_enabled'] == 1) AND ($bbuserinfo['fieldxx'] == "On"))
{

...

}

The confusing thing with this issue you are having is that it detects and assigns the style initially, but then presents with default subsequently - I'm not sure how it could do that based on what you are reporting.

moonclamp
09-06-2010, 09:41 AM
I'm a bit stumped too, I haven't got any access to different brands of phone to see if it's user error or not.

I'll try your conditional and see if that works, in the meantime I've gone back to the 3.8 plugin. :)

moonclamp
09-06-2010, 10:07 AM
Hmm, that conditional is just getting ignored :S

manofphat
09-06-2010, 04:34 PM
If we can get that conditional to work, count me in!

wierdo124
09-06-2010, 06:19 PM
Doesn't work with android browser...

moonclamp
09-06-2010, 06:57 PM
Doesn't work with android browser...
I know someone using Android with no problems.

wierdo124
09-06-2010, 07:34 PM
How? I installed and enabled and my Droid is pointed to the full version.

wierdo124
09-06-2010, 07:44 PM
I even entered Mozilla/5.0 (Linux; U; Android 2.2; en-us; Droid Build/FRG22D) AppleWebKit/533.1 (KHTML, like Gecko) in the box.

dartho
09-06-2010, 08:54 PM
just enter "Android" in the custom section, and make the style is user selectable

wierdo124
09-06-2010, 09:10 PM
Works. Must be case sensitive...i coulda swore i tried that before and it failed.

Maybe give android a full thing like WinMob and iOS? There's more Android devices than iphones now bro.

djbaxter
09-06-2010, 09:12 PM
Any others that should be entered into the Custom section?

For example, will this work on Blackberry phones as is?

dartho
09-06-2010, 09:32 PM
Works. Must be case sensitive...i coulda swore i tried that before and it failed.

Maybe give android a full thing like WinMob and iOS? There's more Android devices than iphones now bro.

Yeah - that's probably a worthwhile idea

Any others that should be entered into the Custom section?

For example, will this work on Blackberry phones as is?

Blackberry's should be detected.

wierdo124
09-07-2010, 12:13 AM
I had to add Palm. The string was WebOS.

bfdzio
09-07-2010, 02:08 PM
You would be after:
if (($vbulletin->options['mob_detect_enabled'] == 1) AND ($bbuserinfo['fieldxx'] == "On"))
{

...

}

The confusing thing with this issue you are having is that it detects and assigns the style initially, but then presents with default subsequently - I'm not sure how it could do that based on what you are reporting.

This is exactly what is happening to me, with Android (Froyo). I received the mobile style at first only once, then since then it hasn't worked.

dartho
09-07-2010, 09:57 PM
new version released which adds a "disable style override" option and *might* resolve the issue reported by a couple of detection on being triggered on first page visited

Robru
09-10-2010, 04:37 PM
A user with an Appele iPad wants the default style, must I put 'iPad' in the Useragent Exceptions section?

dartho
09-10-2010, 09:09 PM
Yes, that should work

swiftor
09-10-2010, 09:59 PM
Hmm, doesn't seem to work with my iphone (only device I have to try it with).

I have it set to use the mobile style for mobile devices... but it still brings me to the default style. Any thoughts?

Thanks!

dartho
09-10-2010, 10:36 PM
Do you have the mobile style set as user selectable. Double check your settings in AdminCP and take a screen shot to post here if still not working. Thanks

swiftor
09-11-2010, 03:42 AM
I believe these are the relevant screens, and yep, the style is available to anyone, guest or otherwise.

dartho
09-11-2010, 06:31 AM
That all looks correct. I've just connected to your site using my desktop browser with a spooffed USER Agent (pretending to be an iPhone) and got the lightweight style OK. The full style link does not work though, as you have specified not to enable over-ride.

Could you try 2 things. 1 - clear all your cookies, and then if that doesn;t work, log out of vbulletin and clear the cookies again then connect to your site again.

Also try turning off iPhone detection (having Mobiule Detection enabled implicitly catches iPhones also)

masons
09-11-2010, 10:35 AM
Works great! woohoooooooo!

swiftor
09-11-2010, 02:47 PM
strange, i used the user switch agent to manually add the user agent of my iphone 4, and it works in my browser then. but no matter what i do, I can't get it to work on my actual iphone4. cleared cache/cookies/history. restarted iphone for good measure. not logged in. still doesn't work, haha.

i'm going to ask some of my users to try it out, if its just me I don't mind.

Many thanks for your awesome products and excellent responsiveness. you rock.

here is the user agent just for reference:

Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7

struff
09-12-2010, 09:52 PM
This is sending ALL my users (not just mobile users) to the Mobile skin. Using IE and Chrome. Did I miss something in the settings?

Thanks.

dartho
09-12-2010, 10:00 PM
Sounds like it - have you enabled custom useragent detection with no data?

struff
09-12-2010, 11:05 PM
Sounds like it - have you enabled custom useragent detection with no data?

Aaah. That was it. Thank you!

wickedstangs
09-17-2010, 04:07 AM
Installed and not sure if its working?

dartho
09-17-2010, 05:39 AM
Doesn't look like it - have you installed a style for detected devices and configured it? You have no selectable style son your site that I can see...

Atakan KOC
09-21-2010, 10:13 AM
Not working.

dartho
09-22-2010, 12:19 AM
Yes it is :)

demonfatal
09-24-2010, 05:30 PM
The old version 3.7 is working fine with Vb4.X, this new one have a lot of problem for detect some device and some navigator...
So uninstalled and old version re-installed and all is fine! :p

Taurus MFF
10-02-2010, 04:30 PM
working great, installed!

is there a way to add an option to automatically direct someone to a specific location if they are detected to be coming in on a mobile device?

I'd like to have auto-detected mobile visitors be sent directly to forum.php instead of content.php

edit: in the meantime I used your advice found here (https://vborg.vbsupport.ru/showpost.php?p=2097867&postcount=83) so people can just click through after an explanation

8thos
10-08-2010, 03:34 AM
It automatically detects mobile phone use but when I click on desktop link, it sends me right back to mobile style.

What am I doing wrong?

dartho
10-08-2010, 07:23 AM
have you enabled detection override and are cookies enabled on your device?

johkalhaups
10-09-2010, 01:26 AM
I cant get this to detect my Pantech Reveal and I had no problems with the 3.8 version.

Gomojoe
10-11-2010, 11:10 PM
So I've installed it and it works, but trys to use the syle on my homepage which is a CMS homepage with articles and such. Is there a method to have it go directly to the forums page when it autodetects instead of my homepage?

RTWAP
10-26-2010, 04:17 AM
Getting the following error when the plugin is enabled:

Warning: preg_match() [function.preg-match]: Unknown modifier ' ' in [path]/includes/class_bootstrap.php(890) : eval()'d code on line 39

dartho
10-26-2010, 05:29 AM
Getting the following error when the plugin is enabled:

turn off custom useragent detection if you have no user agents defined

OldSchoolDSL
10-26-2010, 05:36 AM
Installed and working 4.0.8

It would be nice though if you either added full CMS & Blog support or if not that, edit this mod to automatically direct them to the forum.

dartho
10-26-2010, 06:48 AM
CMS/Blog support has little to do with this mod, that would be up to the style to support. My styles don't but I'm sure others out there do. Also, vBulletin will be releasing a mobile/lightweight style soon which I'm sure will support both!

Dexter_kcd
10-29-2010, 07:50 PM
Dartho,

I think there is a conflict between this mod and the Everywhere Sidebar 4 VB4 (https://vborg.vbsupport.ru/search.php?searchid=16727150) mod. The ESB mod includes an option to exclude styles from showing the sidebar. Obviously most sites do not want to show a sidebar in a mobile style, so they enter their mobile style id number into the option. But as I outline in this post (https://vborg.vbsupport.ru/showpost.php?p=2115797&postcount=663), it seems that if a mobile style is chosen manually, the exclusion works. If the style is automatically via your mod, the exclusion gets ignored, and the sidebar ends up being shown in the mobile style.

Is there something in the way your mod is identifying the styleid of the forced mobile style that would conflict with another mod identifying it?

Dexter...

dartho
10-29-2010, 10:16 PM
The sidebars everywhere hack is only checking what the users default style is, not what style is currently in use. Also, it is checking on global_start which happens before the mobile detect add-on does it's business and possible changes the style, modifying that particular plugin would not work anyway.

If you are using the Lightweight (https://vborg.vbsupport.ru/showthread.php?t=249277)style I wrote, try installin the Lightweight STyle Options addon and add the line
// disable ESB
global $bbandSBactive=0;
to the disable add-ons section

Cicada
10-29-2010, 10:39 PM
awesome. bookmarking

Dexter_kcd
10-29-2010, 10:43 PM
The every style hack is only checking what the users default style is, not what style is currently in use. Also, it is checking on global_start which happens before the mobile detect add-on does it's business and possible changes the style, modifying that particular plugin would not work anyway.

If you are using the Lightweight (https://vborg.vbsupport.ru/showthread.php?t=249277)style I wrote, try installin the Lightweight STyle Options addon and add the line
// disable ESB
global $bbandSBactive=0;
to the disable add-ons section


Yes, I am using your style. I will give this a try over the weekend and see how it works. Thanks for the quick reply, and thanks for these great add-ons. My members appreciate the mobile style a lot.

Cheers,

Dexter...

dartho
10-29-2010, 11:40 PM
Sorry - where I said "The every style hack" - I meant the "The sidebars everywhere hack", but all else remains same

Dexter_kcd
10-30-2010, 04:20 AM
I knew what you meant. :)

Unfortunately, that code did not do the trick. I added it to the disable addons option area just as you instructed, logged out from my iPhone, cleared cookies/cache/history, and then browsed to my site. The sidebar is still there. Do you have any other suggestions?

Dexter...

dartho
10-30-2010, 06:07 AM
This might work - edit all the everysidebar templates in the lightweight style only, and delete the entire contents of each one

Dexter_kcd
11-15-2010, 04:04 AM
This might work - edit all the everysidebar templates in the lightweight style only, and delete the entire contents of each one


Hi Dartho,

I finally had time to go back to this problem. The above suggestion worked. I will post it in the thread for the ESB mod.

Thanks for your help.

Dexter...

steve1966
11-23-2010, 08:48 PM
hi my mobile devices are not being detected i have to use the style changer what have i done wrong to show the light style

edit if i use i older version 3.7 version it detects but when i click on pc mode it will not change back to the default style any ideas please it still does not detect using the 4.o or 4.01

dartho
11-23-2010, 11:52 PM
clear your cookies, or if you want to be selective, just clear he cookies for your site and try again. As soon as you manually select a style, you are effectively turning off auto-detection. In theory, closing all your browser windows should then re-instate it, but it depends on your browser.

steve1966
11-24-2010, 06:25 AM
clear your cookies, or if you want to be selective, just clear he cookies for your site and try again. As soon as you manually select a style, you are effectively turning off auto-detection. In theory, closing all your browser windows should then re-instate it, but it depends on your browser.

Thank you

SnapOff Racing
12-04-2010, 09:41 PM
Would be nice if we could get this working with vB 3.8 as having the option to allow users to decide on whether or not they actually want to view a mobile version is the way to go.

dartho
12-05-2010, 04:13 AM
Did you try it? As mentioned in teh first post, it probably will work

rughis
12-05-2010, 08:16 AM
Excellent mod. It works without any problem on my 4.0.8 vBulletin site.

Thank you!

SnapOff Racing
12-05-2010, 07:42 PM
Did you try it? As mentioned in teh first post, it probably will work

Yeah I tried it on VB 3.8.6 & 3.8.7b1 and it doesn't work at all. I even uninstalled the 3.8.6 version of this mod FIRST which was working just fine. Then I installed this version and it wasn't having any affect whatsoever. I was testing with my iPhone 4.

dartho
12-05-2010, 08:21 PM
try again , but clear cookies first. If you have manually chosen a style at any time, you have essentially overridden autodetection

Joxpa
12-06-2010, 11:34 PM
worked 1 time, after didnt worked again. also not using this:

http://www.testiphone.com/
http://emulator.mtld.mobi/emulator.php

:(

vidan
12-07-2010, 12:02 AM
this mod work with vb4.1? can someone confirm it?
thanks

OldSchoolDSL
12-07-2010, 06:04 AM
Uninstalled.

BadgerDog
01-01-2011, 01:38 PM
Installed with thanks ... :)

I'm not sure how to test it?

Can someone with a PDA access our site and let me know if it works and I have it set up right? Thanks ...

Also, I have a 56kb dial-up users who complain the site is slow for them using a regular PC and browser, so I was wondering if this mod could be adapted to recognize a 56kb dial-up user and automatically present Dartho's great "Lightweight Style"?

I know our Google Analytics code reads data from someplace and shows me analysis of type of connect speeds used when accessing our site, so I think it's possible?

Regards,
Doug

el diablo
01-02-2011, 07:49 PM
Not working for 4.1

smnet
01-18-2011, 01:09 PM
Not working for 4.1

Can you be a little more specific?

Does it break your board, work partially? Error messages?

rowedf
02-08-2011, 06:41 PM
My mobile phone isn't detecting it and my board is on 4.1 as well. I'm using an HTC EVO 4 that is running Android 2.2

siriuxs
02-25-2011, 11:41 AM
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

kether1
02-26-2011, 02:42 PM
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

dartho
02-26-2011, 10:59 PM
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 ...

kether1
02-28-2011, 08:04 PM
I don't own any "i" devices to test, but I believe it should ...

Thank you!

WinnipegHeights
03-07-2011, 02:21 AM
Any ETA on an update for this to work with 4.1+?

bigrover
03-07-2011, 03:58 PM
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.

McCarron
03-29-2011, 06:43 PM
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?

dartho
03-29-2011, 09:17 PM
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.

McCarron
03-30-2011, 07:56 PM
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.

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.

dartho
03-30-2011, 11:53 PM
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
$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|wa p|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'], 0, 4)),
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.

ViewMy.biz
05-09-2011, 08:23 PM
I am migrating soon to a new server and havent redirected my url yet. The force mobie that comes with 4.1.3 does not work for my win 5.5 mobile phone and I can't test other phones until I go live with my new server.

Once I pick the lightweight style Dartho's light style works great unless I have a forum with a forced style.

Can this add on work with 4.1.3, or is forced already working for everyone but me?

here is my beta http://69.64.89.197

S_E_A
05-13-2011, 06:12 PM
Hello dartho,

I may have come across a problem:

new posts -> last page -> redirects to forum index rather than last page of thread?

Danny M
07-10-2011, 07:59 PM
Does this also work on iPods?

alhindasi
07-26-2011, 09:38 PM
this mod use mobile skin in google chrome can you fix it please

wullieclsfb
08-24-2011, 01:06 PM
not detecting mobile style in vbulletin 4.1.5 pl1

dartho
08-24-2011, 09:37 PM
vbulletin 4.1.2 and above has it's own mobile detection, use that instead.

rapung
11-08-2011, 02:24 AM
I dunno what to do with this. It didn't work when I tried to open my forum by a cell phone. Is there anything I missed ?

Amadeusmq
11-24-2011, 09:22 PM
Does this addon require that the setting "Allow Users To Change Styles" be set to YES in the admin control panel?

I prefer to maintain a single style for the site (so I don't let the style be changed); however, I would love to be able to offer mobile (small screens) a different style.

dartho
11-24-2011, 09:26 PM
No - no need to allow users to change styles, but the style must be user selectable (ie. have a tick in teh checkbox next to it in admincp, Style Manager)

Amadeusmq
11-24-2011, 09:30 PM
No - no need to allow users to change styles, but the style must be user selectable (ie. have a tick in teh checkbox next to it in admincp, Style Manager)

Hmmm...then I must be doing something wrong.

Here is the agent string for my Samsung Charge:


xxxxx.myvzw.com - - [24/Nov/2011:14:18:14 -0800] "GET /forums/cpstyles/darkvision/statusicon/forum_old-48.png HTTP/1.1" 200 3940 "http://www.isxgames.com/forums/" "Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; SCH-I510 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"


I tried putting "Mobile Safari" in the "Custom/User Defined Useragent String" SETTING (by itself). That didn't seem to do anything. Do I need to put the entire string?

dartho
11-25-2011, 02:58 AM
You need to be aware that since vb 4.12 (I think) vBulletin have had their own mobile detection script built in - you should check this in your settings to make sure there are no conflicts. It may even suit your purposes in which case you can disable this one (worth doing as part of your testing anyway)

And All android devices should be detected without need for custom useragent strings

|Jordan|
01-23-2012, 07:08 AM
Firefox 10 is being detected as a Mobile device.

dartho
01-23-2012, 07:57 AM
Have you enabled custom useragent detection with the term "firefox" in thje custom useragents? If so, disable it, or remove "firefox".

ALso double check vBulletins detection settings

Skyrider
02-07-2012, 10:04 AM
Installed, didn't detect my Dolphin Browser HD browser on my HTC Desire HD mobile. Still used the default forum style.

dartho
02-08-2012, 12:08 AM
vbuletin has it's own detection system in place - this is no longer required. That being said, I use Dolphn - I will check

res6cue
02-08-2012, 03:52 AM
vbuletin has it's own detection system in place - this is no longer required. That being said, I use Dolphn - I will check

I just jumped from 4.1.0 to 4.1.10 and noticed there is now native vB detection. However your mod has a lot more options. So I guess the question is, does this mod still work and will options I set override the native vB detection or no?

dartho
02-08-2012, 05:14 AM
There is a bug with the vbiulletin detection which is to be fixed in 4.1.11 - I'm not sure how this affects this detection script. What I suggest you try is:
Configure the vB detection to 'none' in AdminCP
Apply this fix for 4.1.10 as detailed here: https://vborg.vbsupport.ru/showthread.php?p=2289299#post2289299

then try again and see how it goes. I just check UA generated by Dilphin - and it uses the word "Android" so should be detected a a mobile device.

Filgga
05-23-2012, 05:17 AM
dartho, this plugin is VERY IMPORTANT than the inbuilt vBulletin's detection script.

Can you consider making it compatible with vB Version: 4.2.x?

Thanks

edytwinky
06-04-2012, 12:58 AM
Anybody able to get this to work with vb 4.2?

The Rocketeer
06-25-2012, 01:18 AM
i would also like to see this work with vb 4.2

dartho
08-21-2012, 02:41 AM
What exactly doesn't work?

Filgga
08-21-2012, 07:48 AM
What exactly doesn't work?
The easiest way to get devices detected is to clear system cache:

http://www.yourdomain.com/admincp/misc.php?do=clear_cache

If you have vB Optimise Installed, do flush the cache:

http://www.jamiiforums.com/admincp/vboptimise.php?do=flush

Mark_Zuckerberg
09-30-2012, 06:53 PM
It also changes my forum skin on PC tooo :(

Robbed
10-03-2012, 12:41 AM
What exactly doesn't work?

It's redirecting to normal skin for some phones and on pc.

When I used to go to mobile site from a pc it would assign the mobile skin and now it doesn't same with some phones and new post for some reason.

freeones_raymon
10-03-2012, 12:36 PM
Hi,

Thanks for this great modification! It's sad that vBulletin doesn't have a good build-in functionality for this, but hey... it's vBulletin!

I only found 3 mobile phones/browsers not being detected as mobile, and these are the user agent strings:

Opera/9.80 (Android 2.3.3; Linux; Opera Mobi/ADR-1207201819; U; sv) Presto/2.10.254 Version/12.00
Opera/9.80 (Android 4.0.3; Linux; Opera Mobi/ADR-1207201819; U; en) Presto/2.10.254 Version/12.00
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Safari/530.17 Skyfire/2.0


I think the first 2 can be defined as "Opera Mobi", and someone told me it was better to add "Opera Mini" to the mobile list as well.

Only the last one was the Skyfire browser on a HTC mobile phone, but I cannot find anything in the user agent string that identifies it as a mobile phone. It even looks like the browser has user agent override enabled or something, but I couldn't find anything in the settings.

So if "Opera Mobi" and "Opera Mini" can be added to the mobile detection list for the next version, thanks!

Regards,
Raymond

sinomama
01-16-2013, 09:27 PM
My vbulletin is 3.8.5.

To avoid being forced to use the lightweigh style for some users, I uninstalled the previous version and installed this version, and with pleasure I chose yes to Enable Over-riding of Styles..........but neither iPad, nor iPhone can detect the lightweigh style which is assigned to all mobiles in the setting of this plugin.

But if I open by the adress http://mydomain.com/forum.php?styleid=nn, the lightweigh style works in safari of iPad or iPhone, and I can return to the original style by cliquing "default style".
It's great!

Finally, Assignment doesn't work for 3.8.5? :(

behcet
07-31-2013, 06:59 PM
upgrade pls

Mark93x
09-07-2013, 10:17 PM
Dartho please update this to 4.2.x

sadiq6210
01-17-2014, 07:38 AM
Already there is an option in vBulletin admincp to choose the default mobile style, what this mod will add?

Thanks

madness85
02-26-2014, 11:42 AM
Using 4.2 can seem to change back to PC mode

oldfan
03-12-2014, 02:42 PM
This not work with 4.2.2?

asabet
01-29-2015, 10:42 PM
I'm using it with 4.2.2. Bit quirky but still works.

Mathsman
03-10-2015, 07:48 PM
thank you so much

pulptoon
04-20-2015, 10:27 PM
After you install this, what do you do? Sorry..newbie

ruchemist
01-22-2016, 04:32 PM
Hi,
Is it possible change style depending on resolution of screen? Also this mod cannot detect tablet computers.

bridge2heyday
01-22-2016, 04:54 PM
Why people is still using that mod ?? .. it is now a native feature of vbulletin AFAIK !

ruchemist
01-22-2016, 05:50 PM
In 3.8 it is not a native feature.

dartho
01-23-2016, 12:07 PM
Hi,
Is it possible change style depending on resolution of screen? Also this mod cannot detect tablet computers.
Sorry - No and no. You can add exceptions for tablets such as "iPad"

AG3000
06-01-2016, 05:28 PM
This add-on brings the big advantage of allowing the user to overwrite the automatic assignment, and it even seems to work well with VB 3.8.9 - thank you very much!

Rhodium
07-31-2016, 06:13 PM
I was having this issue https://vborg.vbsupport.ru/showpost.php?p=2178819&postcount=87 so i changed this line:

if (($_COOKIE["override"]=="on") && ($vbulletin->options['mob_detect_override']==1) && ($vbulletin->options['mob_detect_enabled'] == 1)) {
$ciao=1;
}


to

if (($_COOKIE["bb_userstyleid"]=="$styleid") && ($vbulletin->options['mob_detect_override']==1) && ($vbulletin->options['mob_detect_enabled'] == 1)) {
$ciao=1;
}


And now if i Enable Over-riding of Styles is working fine, i don't have any idea of coding but meh.

dark vengeance
03-07-2020, 07:51 AM
Works on 3.8.11, thank you