|
Post by Justin Burdine on Nov 8, 2010 13:30:56 GMT -6
I've had a few people email me about how to get a browser to redirect for both an iphone and an ipad. Below is untested code, but it should work. If you want to donate so that I can get an ipad to test with I won't argue... ;D <? if (ereg('iPhone',$_SERVER['HTTP_USER_AGENT'])) { $mobile = 1; } elseif (ereg('iPod',$_SERVER['HTTP_USER_AGENT'])) { $mobile = 1; } elseif (ereg('iPad',$_SERVER['HTTP_USER_AGENT'])) { $mobile = 1; } elseif (ereg('Android',$_SERVER['HTTP_USER_AGENT'])) { $mobile = 1; } else { $mobile = 0; } if ($mobile == 1) { header("Location: yoursite.com/ip/picview.php?imgid=$image_id"); } ?>
|
|
|
|
Post by Justin Burdine on Nov 8, 2010 13:35:04 GMT -6
Mikev posted this suggestion over on the PHPMotion boards. I have not tried ths but I thought it was worth posting here. Thanks Mike! here is a pretty handy script for redirecting mobile devices to your iphone template. it works like a charm!
if you have the iphone mod installed in yoursite.com/ip then follow the instructions below if not you will need to change it to suite your needs.
Add the line below to main1.htm just under the <head>
<script src="http://yoursite.com/mobile.js"></script>
be sure to change yoursite.com to your actual site and upload to themes/default/templates/ and overwrite.
Copy the code below to notepad and name it mobile.js Then Change all the "http://www.yoursite.com"s to your actual site and save it. upload to your root directory. Thats it.
// JavaScript Document if (navigator.userAgent.match("Nokia")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("MOT-")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Panasonic")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("SAMSUNG-SGH-")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Sharp")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("SIE-")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("SonyEricsson")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("NEC-")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Siemens")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("LG")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Sony")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Verizon")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Cingular")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Sprint")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("AT&T")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Nextel")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Palm")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Handspring")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("HP")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Tungsten")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Treo")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("T-Mobile")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Pocket PC")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Dell")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Compaq")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Erikson")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Orange")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Casio")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Symbol")) window.location.href="http://www.yoursite.comip"; else if(navigator.userAgent.match("Symbian")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("NEC")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Toshiba")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("LG")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Blackberry")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Motorola")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("Samsung")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("HTC")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("iPhone")) window.location.href="http://www.yoursite.com/ip"; else if(navigator.userAgent.match("iPad")) window.location.href="http://www.yoursite.com/ip";
|
|
|
|
Post by yamasaki on Nov 9, 2010 14:18:09 GMT -6
In addition to above, following works %100 for all mobile phones.
|
|
|
Post by Thiberio on Oct 15, 2012 8:19:57 GMT -6
Hi everyone, I'm trying to install this mod on my phpmotion. I've already installed the template and it is working fine. I would like to redirect but it is not working. I'm using a Galaxy S2 running at Android OS 4.0 and iPhone 4s running at 6.0 iOS for test. Booth are working fine in see the template if I type: mysit/ip or if I type the ip of the site. The point is, The redirect is not working I tried the Mikev mod and this one either tetfxlabs.wordpress.com/2011/12/31/codes-redirect-mobile-users/Both are not working. Any suggest?
|
|