Форумы / Cotonti / Support / Redirect to Mobile theme

12>>>

CJ
#1 14.05.2011 12:39

How would i make my site redirect to a mobile theme on a mobile device ???

Trustmaster
#2 15.05.2011 18:58

First you need to distinct a user of a mobile device somehow. Either by the URL (i.e. use example.com/mobile or m.example.com for mobile devices) or by User-Agent (which are plenty of I suppose). Then, supposing that you use m.example.com for mobiles, you can write in your config.php:

$cfg['defaultskin'] = $_SERVER['HTTP_HOST'] == 'm.example.com' ? 'wap_skin' : 'normal_skin';

 

May the Source be with you!
Отредактировано: Trustmaster (15.05.2011 18:58, 14 лет назад)
GHengeveld
#3 15.05.2011 21:04

Have a look at this site: http://detectmobilebrowsers.mobi

Sergey
#4 16.05.2011 16:14

Have a look at this site: http://www.neocrome.ru/forums.php?m=posts&p=22963#22963

But the operation has identified a number of problems: inconsistency size image text size, inadequate display the UL and LI ....

www.cotonti.mobi
CJ
#5 04.06.2011 14:19

ok so i have a Mobile domian.

I added this to my Config file and it didnt work

$cfg['defaultskin'] = $_SERVER['HTTP_HOST'] == 'm.example.com' ? 'wap_skin' : 'normal_skin';

like i have the stuff from http://detectmobilebrowsers.mobi but idk where to put it so that it work. anyone wana explain ???

urlkiller
#6 27.06.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>
Отредактировано: urlkiller (27.06.2011 02:13, 13 лет назад)
Kingsley
#7 27.06.2011 14:34

Uhm, noobie here..

In this day and age, maybe wise to make it an official cotonti plugin? I mean, the mobile market will only get bigger, so why not integrate it..

But that's just my 2 cents..

urlkiller
#8 27.06.2011 21:47

i would indeed like to see a plugin for that too...

URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
Sergey
#9 27.06.2011 22:10

This plugin made in 2009 for 6.1 Plugin requires additional testing for version 6.17. Work will be completed no earlier than the beginning of October 2011. This is due to the fact that the test is a new module for the pages of mobile phones. http://www.cotonti.com/datas/users/mobilconfig_205.pdf

www.cotonti.mobi
Отредактировано: Sergey (28.06.2011 04:19, 13 лет назад)
urlkiller
#10 27.06.2011 22:27

http://www.cotonti.com/datas/users/mobileskin_39.rar

Added 43 seconds later:

there it is... fully functional. if choosen skins dont exists it dont changes the skin names. tested with ipad, iphone 3 / 4 and android...
URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
CJ
#11 28.06.2011 11:30

@URLKILLER thanks for the link it help !!

urlkiller
#12 28.06.2011 15:32

no problem. hope it works for you... (one problem though is that the user is forced to use the skins you enter in settings. all what he choose in his profile will most likely get overwritten !!!)

URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
CJ
#13 28.06.2011 17:48

well we only have 2 themes the mobile one and the normal one. but im sure there must be a way to make it so when we make more it can set to what u choose

RaisenBran
#14 28.06.2011 18:51

Nope tested it urlkiller and my regular theme doesn't overwrite the mobile plugin, good job smiley

 

Also I have the old Sedito MobileSite plugin, so if you ever run into problems on this MobileSkin plugin you made, I can give you my plugin to look at.

CJ
#15 28.06.2011 21:32

here send it here ill see witch works better for my site

12>>>