• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Mobile Browser Style Switch

Cezz

Well-known member
#1
This is a very simple modification that detects if the user is currently on a mobile browser, and if so sets the styleid to your mobile style.

Please note that this is a very early version of this particular modification and currently has only two options...
  1. Style ID (For the Style you want to set)
  2. User Agent Idents (a comma delimited list of mobile user agent idents you wants to check for)
I plan to add more features to this, including but not exclusively

  • Ability for visitor to overwrite the change and view the full site.
  • Default to no overwrite of style but prompt visitor to change.
  • Ability to exclude certain Controllers from the style overwrite (E.G. if the mobile style isn't coded very well for your homepage, you could use the standard style for that and a mobile style for the rest of the site!)
If you have any more suggestions then let me know.
----------------------------------------------
Installation Instructions :-
  1. Download and Extract .zip file.
  2. Upload contents of Upload folder to your forum root.
  3. Import the .xml file into your admin control panel.
  4. Set the style ID and User Agent Ident fields as desired.
That is it, nice and simple!
 

Attachments

Cezz

Well-known member
#7
Your all more than welcome, for those of you who have installed how are you finding it?

Do you have any suggestions other than what I listed in the first post?
 

HoddzDJ

Active member
#10
a few are using xfstop but it is outdated and not complete. This is more there for when there is a decent mobile style... Though I suspect this mod will become obsolete once the official mobile style is released!
I just wonder if when the mobile style is released, if it will automatically switch to that or if we will still need this mod to change it! I still haven't got it installed yet, but I will ASAP and come back to give my views of it, looks sweet though :)
 

James

Well-known member
#11
Have you looked at XenForo_Visitor::isBrowsingWith($browser)?

You could (I think) do something like:
PHP:
if(XenForo_Visitor::isBrowsingWith("mobile"))
{
// set style
}
 

Carl

Well-known member
#12
a few are using xfstop but it is outdated and not complete. This is more there for when there is a decent mobile style... Though I suspect this mod will become obsolete once the official mobile style is released!
Negative nelly.
 

tmb

Active member
#14
Excellent work.

Anyone know what to put in for blackberry? The other mobile users are having no issue but can't get the right agent for blackberry.
 

Russ

Well-known member
#15
Excellent work.

Anyone know what to put in for blackberry? The other mobile users are having no issue but can't get the right agent for blackberry.
Found a list here: http://www.dannyherran.com/2011/02/...t-with-php-ipad-iphone-blackberry-and-others/

Code:
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-
Hope it works well :)
 

Cezz

Well-known member
#17
Have you looked at XenForo_Visitor::isBrowsingWith($browser)?

You could (I think) do something like:
PHP:
if(XenForo_Visitor::isBrowsingWith("mobile"))
{
// set style
}
I had, and there is probably many things I could do to improve this... However saying that the isBrowsingWith is only checking really for smart phones, IE Mobile Safari, Nokia, Symbian, Windows Mobile, Opera Mini & Blackberry (Wouldn't work for those using Firefox mobile or on older devices)... I wanted mine to be extendible, in fact the default user agents list in my mod includes kindle etc as well.
 

Anthony Parsons

Well-known member
#18
I seriously hope to see this as part of XF in 1.1 to be perfectly honest... this is one really lacking area of XF at present... if not the only one of significance.

Nice work Cezz....
 

James

Well-known member
#19
I had, and there is probably many things I could do to improve this... However saying that the isBrowsingWith is only checking really for smart phones, IE Mobile Safari, Nokia, Symbian, Windows Mobile, Opera Mini & Blackberry (Wouldn't work for those using Firefox mobile or on older devices)... I wanted mine to be extendible, in fact the default user agents list in my mod includes kindle etc as well.
I suppose you could've extended the isBrowsingWith function, but this method works fine so far :)
 

Cezz

Well-known member
#20
I suppose you could've extended the isBrowsingWith function, but this method works fine so far :)
Valid point, didn't even think about it really... may look into doing that actually so that the extended list of mobile devises can be used by other mods also.