Skip to content

Commit

Permalink
Merge pull request #38 from kinglozzer/mobile_request_detection
Browse files Browse the repository at this point in the history
NEW Add mobile site detection for non-mobile domain
  • Loading branch information
wilr committed Feb 22, 2013
2 parents e7f3926 + 231f79e commit eee8db0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
Empty file added .gitignore
Empty file.
21 changes: 21 additions & 0 deletions code/MobileSiteControllerExtension.php
Expand Up @@ -102,6 +102,27 @@ static public function is_mobile() {
return self::$is_mobile;
}

/**
* Return whether the user is requesting the mobile site - either by query string
* or by saved cookie. Falls back to browser detection for first time visitors
*
* @return boolean
*/
public function requestedMobileSite() {
$request = $this->owner->getRequest();
$fullSite = $request->getVar('fullSite');
if (is_numeric($fullSite)) {
return ($fullSite == 0);
}

$fullSiteCookie = Cookie::get('fullSite');
if (is_numeric($fullSiteCookie)) {
return ($fullSiteCookie == 0);
}

return MobileBrowserDetector::is_mobile();
}

/**
* Return whether the user is on the mobile version of the website.
* Caution: This only has an effect when "MobileSiteType" is configured as "RedirectToDomain".
Expand Down

0 comments on commit eee8db0

Please sign in to comment.