I have a question. For my Joomla site I made two different templates. One template a desktop version and the other one is for mobile use.
Both templates working fine, the desktop is the default template.
But i like to have a mobile recognition and redirect script, that redirects mobile users to the url www.domain.nl/mobiel (this url has got the mobile template)
Now i have a php code implemented into the default (desktop template). This code redictects the mobile user to this url. The script works fine.
And on the mobile page i have a url that correctly links back to the homepage in desktopmode "http://www.domain.nl/?mode=desktop"
But the issue is that: when the mobile user is in desktop-mode and clicks on a menuitem they automaticly redirects to the mobile page. So i think the possibility is an cookie or something?
<?php
function is_mobiel(){
$regex_match="/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|";
$regex_match.="htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|";
$regex_match.="blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|";
$regex_match.="symbian|smartphone|midp|wap|phone|windows ce|iemobiel|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|";
$regex_match.="jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220";
$regex_match.=")/i";
return isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE']) or preg_match($regex_match, strtolower($_SERVER['HTTP_USER_AGENT']));
}
switch($_GET['mode'])
{
case 'mobiel':
$mode = "mobiel";
break;
case 'desktop':
$mode = "desktop";
break;
default:
$mode = is_mobiel() ? "mobiel" : "desktop";
break;
}
if ($mode == "mobiel")
{
header ("Location: http://www.domain.nl/mobiel?m");
return;
}
?>