I have noticed there is not a lot of help going out from the forum for older templates that use the mobile detection etc.. I have searched through and through so I thought I would put one solution I have found here and include key words like
iphone , mobile, droid, etc...
I added the following lines to my template's index.php above the gantry calls so it would redirect the homepage to the /m-home page I setup in the mobile menu as the homepage there.
The problem I was having was my / page was not loading well in the mobile version so I wanted the mobile version when the full url was entered to actually redirect to the /m-home page I setup in the mobile-main menu.
I have alternate content and modules all published for the mobile versions.
Here is the PHP that sniffs out if we are on the homepage - and then sniffs out the browser. I have not tested this on droid, but have on my iphone. Any droid users let me known what happens.
basically --
martysimpson.com
loaded in a droid should redirect to /m-home.
Thanks.
CODE snippet below
// put this right after the Restricted_access line from joomla.. in the template's index.php file.
$menu = & JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
// Written By Adam Khoury @ developphp.com - March 26, 2010
// PHP mobile browser detection ready Home Page(index file that detects and redirects)
// Simply find the device OS or browser label and place conditionals as needed
$agent = $_SERVER['HTTP_USER_AGENT']; // Put browser name into local variable
if (preg_match("/iPhone/", $agent)) { // Apple iPhone Device
// Send them to iphone sized homepage for mobile
header("location: /m-home");
} else if (preg_match("/android/", $agent)) { // Google Device using Android OS
// Send them to android sized homepage for mobile
header("location: /m-home");
}
}