Load Mobile Sie on Mobile NOT Tablet!

I’m using mobiledetect.net to render a mobile version of my site {m.mysite.com) but now tablets are so popular, I want the desktop site to load on such devices - what do I need to change?

This is the code I currently have at the top of my desktop version:

<?php
@include("Mobile_Detect.php");
$detect = new Mobile_Detect();
if ($detect->isMobile() && isset($_COOKIE['mobile']))
{
$detect = "false";
}
elseif ($detect->isMobile())
{
header("Location:http://m.mysite.com");
}
?>

I’ve read that I need to add this:

if ($detect->isMobile() && !$detect->isTablet())

Bu I’m not sure how to implement it with the cookie control I have?

Well I seem to have solved it within seconds of posting! So for anyone else (& if anyone who knows php better than me can cast an experienced eye over it) here’s the amended code:

<?php @include("Mobile_Detect.php"); $detect = new Mobile_Detect(); if ($detect->isMobile() && !$detect->isTablet() && isset($_COOKIE['mobile'])) { $detect = "false"; } elseif ($detect->isMobile() && !$detect->isTablet()) { header("Location:http://m.mysite.com); } ?>

Why are you creating multiple site versions. All you need to do is make ONE responsive site and it will work everywhere. I suggest you take a look at bootstrap.

Partly true, a responsive site is often a small compromise for it to work on all platforms. Also bootstrap will not help you if one of your concerns is data transfer. Ie, if you have a lot of data/components that are hidden on mobile they will still have to be transferred from the server to the client.

A fully responsive site is one option - the other is the option I am using - both are accepted by Google for their pending April change to how they rank websites/mobile sites.

It is often complicated and a compromise in many areas to make a site fully responsive on the myriad of different platforms - it’s a direction I for one will try to avoid while a separate, m. mobile site works.

It is often complicated and a compromise in many areas to make a site fully responsive on the myriad of different platforms

As far as bootstrap goes, your statement is not true at all. Bootstrap is a “Mobile First” (ver 3.x) framework and is not complicated whatsoever. It scales perfectly to ANY device.

What I mean is I code everything myself, day in day out for all sorts of clients - and if one asks me to make their existing website mobile friendly, then I’m afraid such things aren’t much help.

Sponsor our Newsletter | Privacy Policy | Terms of Service