This thread is an attempt to at least partially reclaim some of the information from our now lost conversation. This topic concerns Google’s change to their website rankings based on mobile friendliness of said sites. The most significant contribution in my opinion was made by Wim, but others also shared their preferred techniques to preserve full site access while meeting Google’s standards. The salient points of this thread could be very helpful to anyone who is trying to comply with ‘Mobile Friendly’ criteria. Also bear in mind that Mobile Redirection isn’t Google’s preferred method of meeting their mobile standards.
Wim posted the, for me anyway, the critical technique for such redirection because it preserved access to the full web site from a mobile phone, didn’t insist that tablets be at first shunted off onto the mobile track, and met Google’s criteria regarding mobile friendliness.
There is a script, called ‘Mobile_Detect.php’ that performs all of the grunt work in checking for mobile platforms when users access a web site. It is available here and more information is on Github.
Using it with the Saratoga template via Wim’s technique is fairly straightforward. The ‘Mobile_Detect.php’ script should be downloaded and placed in the root of your site. Then the following code should be added to ‘top.php’ (context included):
//Version V3.04 - 05-Feb-2013 - added support for HTML5+UTF8
############################################################################
$cookie = 'mobile_skip'; // or use your own name
#
$redirect_mobi = 'http://your.mobile.sites/mobilepage'; // set to your mobile site/page
#
$mobile = false; // default we do not go to the mobile site
if (!isset ($_COOKIE[$cookie])) {
require_once 'Mobile_Detect.php'; // credits : http://mobiledetect.net/
$detect = new Mobile_Detect;
if( $detect->isMobile() && !$detect->isTablet() ){
$mobile = true;
if (isset ($_REQUEST['pcSite']) || isset ($_SESSION['pcSite']) ) {
$mobile = false;
} // eo if pcSite
} // eo detect mobile
if ($mobile == true) {
header ("Location: $redirect_mobi"); // go to the mobile site
exit;
} // eo is mobile
} // eo cookie set
setcookie($cookie, "skip", time()+3600); // cookie expires in 1 hour
Then you need to add the ‘?pcSite=Y’ to the link to your main site in ‘cell-footer.php’ for the ‘cell.php’ mobile scripts
<a href="http://your.web.site/index.php?pcSite=Y">View the full version</a>.</div>
and/or to ‘AltAjaxDesktopConfig6.php’
$mainsite = "index.php?pcSite=Y"; // Path and name of main site for mobile site's button to display full dashboard
if you use Scott Thompson’s ‘WWL-mobile.php’.
Briefly, anytime your web site is loaded unless the $cookie is set ‘Mobile-Detect.php’ checks for a mobile viewer. The code then redirects to the site’s mobile page(s) when a mobile viewer NOT a tablet is detected while also setting the $cookie. If the mobile viewer requests the main site however, it’s available because redirection won’t occur until the $cookie expires.