Solved

How do I fix a php mobile detect and redirect script to allow users on mobile devices to see the full site

Posted on 2016-09-27
4
169 Views
Last Modified: 2016-11-05
I have this script at the top of my code:

<?php
error_reporting(E_ALL ^ E_NOTICE);
 session_start();
$refering_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
//echo $refering_url;
if (strpos($refering_url,'mobile/ab-moving-storage-mobile.html') !== false) {
    //echo 'true';
	$_SESSION['last_url']=$refering_url;
}
else
{
//echo "else condition...";
if($_SESSION['last_url']=="") {
 require_once('mobile_device_detect.php');
mobile_device_detect(true,true,true,true,true,true,true,'http://www.abmoving.com/mobile/ab-moving-storage-mobile.html',false);
}
//$_SESSION['last_url']="";
}

?>

Open in new window


It redirects with no problem, but when "Go to Full Site" is clicked from the mobile version of the page, it will not display the full site version on the mobile device. It redirect to the mobile version

The desktop page: abmoving.com/ab-moving-storage.php
The mobile page: abmoving.com/mobile/abmoving-storage-mobile.html

We are working on a responsive site but I need this in the meantime.
0
Comment
Question by:weknowjack
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 400 total points
ID: 41819640
you must add a parameter in the "Go to Full Site" link/button.

so you can check if it was a click from it :

$gotoFullSiteClicked = $_GET["gotofull"] == "1"; // check if the parameter gotofull is set to 1

else if($gotoFullSiteClicked)
{
   // go to full site

Open in new window

0
 

Author Comment

by:weknowjack
ID: 41819668
Thank you, but I am not a coder. Where would this parameter be placed? In the non-mobile page?
0
 
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 100 total points
ID: 41826559
Been out of town for a few weeks and returned today.  Got a neglected question alert on this one.  Here is my take on the question.

The trend from desktop to mobile "tipped" in 2012.  Nobody uses mobile detection any more.  The assumption today (2016) is that all accesses are coming from mobile first.  This means that we design for mobile, and let desktop be the graceful fallback.  To that end, tools like Twitter Bootstrap are the right way to go.  The interim step of trying to shoehorn an old desktop site into some kind of mobile-friendly structure may not be value-added.  In my experience, it's faster and gets better results, if you just refactor the old site (only once).

Also, you really need a coder to handle this.  It's worth the investment to get it completely right, and the results will likely serve you well for a long time!
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question