Commit 4d265faf authored by Rob Loach's avatar Rob Loach
Browse files

Add subdomain mobile detection

parent e76ffc2c
Loading
Loading
Loading
Loading

README.md

0 → 100644
+24 −0
Original line number Diff line number Diff line
Mobile Theme
============

Adds the ability to choose a mobile theme in *admin/build/themes/settings*.


Mobile Detection
----------------

Choose which detection method is used to find whether or not the user is on a
mobile device at *admin/build/themes/settings*:

* PHP
* get_browser
* m. Subdomain
* Browscap
* mobile_device_detect.php


More Information
----------------

If you're looking for a more advanced solution, please have a look at Mobile
Tools or iDrupal. Mobile JS Redirect is another great solution.
+13 −2
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ function mobile_theme_custom_theme() {
    $method = "mobile_theme_detect_php";
  }

  // Check if this is a mobile 
  // Check if the mobile theme is to be used.
  $mobile_device = $method();
  if ($mobile_device) {
    $theme = variable_get('mobile_theme_selection', 'default');
@@ -74,6 +74,9 @@ function mobile_theme_mobile_theme_detection() {
  $detection_methods = array(
    'mobile_theme_detect_php' => t('PHP'),
    'mobile_theme_detect_getbrowser' => t('get_browser'),
    'mobile_theme_detect_subdomain' => t('!m Subdomain', array(
      '!m' => variable_get('mobile_theme_subdomain', 'm.'),
    )),
  );

  // Support Browscap module if available.
@@ -142,6 +145,14 @@ function mobile_theme_detect_browscap() {
  }
}

/**
 * Detect whether the user is on a mobile device by checking the subdomain.
 */
function mobile_theme_detect_subdomain() {
  $m = variable_get('mobile_theme_subdomain', 'm.');
  return substr($_SERVER['HTTP_HOST'], 0, strlen($m)) === $m;
}

/**
 * Detect whether the user is on a mobile device by using Mobile Device Detect.
 */