Foren / Cotonti / Support / Redirect to Mobile theme

urlkiller
#29929 27. Juni 2011, 01:57
$cfg['defaultskin'] = $_SERVER['HTTP_HOST'] == 'm.example.com' ? 'wap_skin' : 'normal_skin';

this code switches the variable that stores the name of the skin the user (guest) will see on your page.
the above expression is more like a "switch" for 2 possible values IF the user enters via m.example.com.
it can be either "wap_skin" or "normal_skin"

with knowing that i would asume it dont works for you because you simply
dont have 2 skins with the names "wap_skin" and "normal_skin".

sooo.. you need to have 2 skins. one that is optimiced for the use with mobile devices and
one that is layouted to fit regular machines. then you would need to setup the correct names replace wap_skin with the name of the skin optimced for the mobile use and normal_skin with the name of the skin you normaly want to use. Dont forget to change m.example.com to your desired adress.

 

hope it helps

 

 

Added 6 minutes later:

ahh yes autodetect. that would need some more work and a list with the browser user-agents (http://de.wikipedia.org/wiki/User_Agent#Mobilfunkger.C3.A4te <= thats german because the list wasnt in the english version!).

but that would be the hard way.

Koradhil's solution was to use that little framework for detecting if its a mobile device or not. with that and a little plugin you could do a simple autodetection.
the plugin would be only a few lines of code and pretty simple since you really only need to have 2 lines for detection and 1 line more for changing the skin variable.
 

Added 8 minutes later:

ok thats so easy stuff... (nice tipp Koradhil)

you can try that (put that at the end of your config.php and make sure the mobile_devices_detect.php is also in that folder ):

require_once('mobile_device_detect.php');
$m = mobile_device_detect(true,true,true,true,true,true,true,false,false);
$cfg['defaultskin'] = $m ? '<MOBILE SKIN NAME>' : '<NORMAL SKIN NAME>';

that code changes the var of the skin (yes like above) but it uses $m (that can be TRUE/FALSE) to select either the first or the sencond argument.

URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>

Dieser Beitrag wurde von urlkiller (am 27. Juni 2011, 02:13, vor 12 Jahre) bearbeitet