Select theme, language by browser locale [message #158937] |
Fri, 17 April 2009 13:56 |
Peter Vendike
Messages: 65 Registered: February 2009 Location: Denmark
Karma: 0
|
Member Translator |
|
|
With SMF vers. 2 you can make a installation where the language follows browser locale, so users are not forced to select theme/language in personal settings.
Would by nice to have the same in FUD, possibly as default theme.
Peter
|
|
|
|
|
|
|
Re: Select theme, language by browser locale [message #159062 is a reply to message #158937] |
Thu, 30 April 2009 23:44 |
Ernesto
Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
|
|
It seems you can do it in two ways.
Either you can redirect with htaccess or directly with an apache module, so I guess one can set up a forum copy on a different folder, but connect to the same database, since I think the default/allowed themes are controlled from the GLOBALS file and not the database, right?
I found this PHP example:
<?php $isMobile = false;
$isBot = false;
$op = strtolower($_SERVER['HTTP_X_OPERAMINI_PHONE']);
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
$ac = strtolower($_SERVER['HTTP_ACCEPT']);
$ip = $_SERVER['REMOTE_ADDR'];
$isMobile = strpos($ac, 'application/vnd.wap.xhtml+xml') !== false
|| $op != ''
|| strpos($ua, 'sony') !== false
|| strpos($ua, 'symbian') !== false
|| strpos($ua, 'nokia') !== false
|| strpos($ua, 'samsung') !== false
|| strpos($ua, 'mobile') !== false
|| strpos($ua, 'windows ce') !== false
|| strpos($ua, 'epoc') !== false
|| strpos($ua, 'opera mini') !== false
|| strpos($ua, 'nitro') !== false
|| strpos($ua, 'j2me') !== false
|| strpos($ua, 'midp-') !== false
|| strpos($ua, 'cldc-') !== false
|| strpos($ua, 'netfront') !== false
|| strpos($ua, 'mot') !== false
|| strpos($ua, 'up.browser') !== false
|| strpos($ua, 'up.link') !== false
|| strpos($ua, 'audiovox') !== false
|| strpos($ua, 'blackberry') !== false
|| strpos($ua, 'ericsson,') !== false
|| strpos($ua, 'panasonic') !== false
|| strpos($ua, 'philips') !== false
|| strpos($ua, 'sanyo') !== false
|| strpos($ua, 'sharp') !== false
|| strpos($ua, 'sie-') !== false
|| strpos($ua, 'portalmmm') !== false
|| strpos($ua, 'blazer') !== false
|| strpos($ua, 'avantgo') !== false
|| strpos($ua, 'danger') !== false
|| strpos($ua, 'palm') !== false
|| strpos($ua, 'series60') !== false
|| strpos($ua, 'palmsource') !== false
|| strpos($ua, 'pocketpc') !== false
|| strpos($ua, 'smartphone') !== false
|| strpos($ua, 'rover') !== false
|| strpos($ua, 'ipaq') !== false
|| strpos($ua, 'au-mic,') !== false
|| strpos($ua, 'alcatel') !== false
|| strpos($ua, 'ericy') !== false
|| strpos($ua, 'up.link') !== false
|| strpos($ua, 'vodafone/') !== false
|| strpos($ua, 'wap1.') !== false
|| strpos($ua, 'wap2.') !== false;
$isBot = $ip == '66.249.65.39'
|| strpos($ua, 'googlebot') !== false
|| strpos($ua, 'mediapartners') !== false
|| strpos($ua, 'yahooysmcm') !== false
|| strpos($ua, 'baiduspider') !== false
|| strpos($ua, 'msnbot') !== false
|| strpos($ua, 'slurp') !== false
|| strpos($ua, 'ask') !== false
|| strpos($ua, 'teoma') !== false
|| strpos($ua, 'spider') !== false
|| strpos($ua, 'heritrix') !== false
|| strpos($ua, 'attentio') !== false
|| strpos($ua, 'twiceler') !== false
|| strpos($ua, 'irlbot') !== false
|| strpos($ua, 'fast crawler') !== false
|| strpos($ua, 'fastmobilecrawl') !== false
|| strpos($ua, 'jumpbot') !== false
|| strpos($ua, 'googlebot-mobile') !== false
|| strpos($ua, 'yahooseeker') !== false
|| strpos($ua, 'motionbot') !== false
|| strpos($ua, 'mediobot') !== false
|| strpos($ua, 'chtml generic') !== false
|| strpos($ua, 'nokia6230i/. fast crawler') !== false; ?>
So, basically, in the theme manager, you can get an option to set also the mobile default theme as well as the regular default theme.
I don't think it should require all too much work to add the functionality, although for sure it will be annoying to make a theme for the mobile, but that is a later headache hehe.
Of course, if there is no real need for such a function in the community, I guess I can tweak myself, but with the increasing mobile browsing market, I think it could be pretty cool.
Ginnunga Gaming
|
|
|
|
|
|
|
|
|
|