Page 1 of 1

Need some help with my script

Posted: Tue Mar 19, 2013 3:00 pm
by HenkvD
For the website of my single-man-company I use Wurfl to redirect mobile users to a mobile version of my website.

This is the script I put in the pages to redirect:

require_once("wurfl/TeraWurfl.php");
$wurflObj = new TeraWurfl();
$wurflObj->getDeviceCapabilitiesFromAgent();
$isWireless = $wurflObj->getDeviceCapability("is_wireless_device");

if($isWireless)
header("location: http://www.m.klussenpunt.nl/index.html");

As an amateur programmer I'm happy the way this works for several years and that I figured this out.

My main website is 1000 pixels width and the mobile website is 300 pixels width.

At this moment all the tablets wil be redirected to the mobile website, and that is unnecessary, a bit annoying even.

The question: could anyone help me provide some script I can use redirecting only the devices with a width smaller than 800 pixels (landscape)?

Re: Need some help with my script

Posted: Tue Mar 19, 2013 5:27 pm
by sm_support2
is_tablet and ux_full_desktop are also your friends.

Pretty much all tablets have double orientation, so telling actual width out of HTTP inspection is impossible.

Responsive Web Design, with Server-Side optimization may be an option you want to explore for Desktop+Tablet:

http://www.scientiamobile.com/blog/post ... sign-(RWD)

Re: Need some help with my script

Posted: Tue Mar 19, 2013 8:57 pm
by kamermans
Here's an updated code snippet:

Code: Select all

require_once("wurfl/TeraWurfl.php");
$wurflObj = new TeraWurfl();
$wurflObj->getDeviceCapabilitiesFromAgent();
$isWireless = $wurflObj->getDeviceCapability("is_wireless_device");
$isTablet = $wurflObj->getDeviceCapability("is_tablet");

if($isWireless && !$isTablet)
header("location: http://www.m.klussenpunt.nl/index.html");

Re: Need some help with my script

Posted: Wed Mar 20, 2013 12:44 pm
by HenkvD
Thanks for the reply,

Server side optimization sounds great but is out of my league for this moment due to the fact that I have not enough time to spend.

The code snippet uses wireless and tablet as condition to redirect to my mobile website.

I think most of the tablets can view my main website perfectly well, so I would like to redirect if the device is wireless and not a tablet.

How can I put this in the code?

Thanks in advance.

Henk (Netherlands)

Re: Need some help with my script

Posted: Thu Mar 21, 2013 3:42 pm
by kamermans
Hi Henk,

The code I posted previously does just that. Note that their is a "!" before $isTablet which means "if is wireless and not is tablet".