NAVIGATION
This shows you the differences between two versions of the page.
|
english:other-enhancements:tools:user-agent [2012/02/24 01:27] Knut Heermann (flip-flop) |
english:other-enhancements:tools:user-agent [2018/06/03 18:09] (current) |
||
|---|---|---|---|
| Line 14: | Line 14: | ||
| E.g.: | E.g.: | ||
| * **{IF-UAG}** //(X/Y -Values for the position in the script)// . | * **{IF-UAG}** //(X/Y -Values for the position in the script)// . | ||
| - | * **{IF-UAG:200:25}** //(200px in X -and25px in Y-direction)//. | + | * **{IF-UAG:200:25}** //(200px in X -and 25px in Y-direction)//. |
| \\ | \\ | ||
| Line 108: | Line 108: | ||
| === Tablets: === | === Tablets: === | ||
| + | **Since version 1.5 (r452) there is no "mobile" output when using tablets.** | ||
| + | |||
| {{ :deutsch:andere-erweiterungen:tools:uag_android-tablet_1.gif|}} | {{ :deutsch:andere-erweiterungen:tools:uag_android-tablet_1.gif|}} | ||
| {{:deutsch:andere-erweiterungen:tools:uag_ios-tablet_1.gif|}} | {{:deutsch:andere-erweiterungen:tools:uag_ios-tablet_1.gif|}} | ||
| Line 121: | Line 123: | ||
| ===== PHP Script: ===== | ===== PHP Script: ===== | ||
| - | *Very simple method:** \\ | + | **Very simple method:** \\ |
| The values of the user agent read directly: | The values of the user agent read directly: | ||
| + | |||
| <code php>dumpVar(phpwcms_getUserAgent());</code> | <code php>dumpVar(phpwcms_getUserAgent());</code> | ||
| Line 301: | Line 304: | ||
| \\ | \\ | ||
| + | |||
| + | \\ | ||
| + | |||
| + | ====== Extracting the OS version from iOS ====== | ||
| + | |||
| + | ==== Version 1.0 ==== | ||
| + | |||
| + | Use within the CMS e.g.: | ||
| + | |||
| + | <!--if:platform:iOS_V3-->iOS Version3<!--/if--> | ||
| + | <!--if:platform:iOS_V4-->iOS Version4<!--/if--> | ||
| + | |||
| + | \\ | ||
| + | **Simple script:** derived from -> [[http://stackoverflow.com/questions/7768324/detect-ios-version-with-php|Detect iOS version with PHP]] | ||
| + | |||
| + | **File:** template/inc_script/**frontend_init**/rt_iOS_OS_user_agent.php | ||
| + | |||
| + | <code php |h rt_iOS_OS_user_agent.php |h> | ||
| + | <?php | ||
| + | /* | ||
| + | ******************************************************************* | ||
| + | * 08.11.2012 KH: Extract the OS from the User-Agent for iOS devices | ||
| + | * | ||
| + | * This solution can be queried with the built in if statements. -> iOS_V4, iOS_V5, iOS_V6 | ||
| + | * | ||
| + | * In CMS e.g.: | ||
| + | * <!--if:platform:iOS_V3-->iOS Version3<!--/if--> | ||
| + | * <!--if:platform:iOS_V4-->iOS Version4<!--/if--> | ||
| + | * | ||
| + | * File: template/inc_script/frontend_init/rt_iOS_OS_user_agent.php | ||
| + | * | ||
| + | ********************************************************************/ | ||
| + | |||
| + | // ------------------------------------------------------------------------------------------- | ||
| + | // obligate check for phpwcms constants | ||
| + | if (!defined('PHPWCMS_ROOT')) {die("You Cannot Access This Script Directly, Have a Nice Day.");} | ||
| + | // ------------------------------------------------------------------------------------------- | ||
| + | |||
| + | // Example USER-AGENT iOS | ||
| + | // -------------------------------------------------------- | ||
| + | // Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5 | ||
| + | // Mozilla/5.0 (iPad; U; CPU OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5 | ||
| + | // -------------------------------------------------------- | ||
| + | |||
| + | if ($GLOBALS['phpwcms']['USER_AGENT']['platform'] == 'iOS') { | ||
| + | |||
| + | $os_vers = preg_replace("/(.*) OS ([0-9]*)_(.*)/","$2", $_SERVER['HTTP_USER_AGENT']); | ||
| + | $GLOBALS['phpwcms']['USER_AGENT']['platform'] = $GLOBALS['phpwcms']['USER_AGENT']['platform'].'_V'.$os_vers; | ||
| + | } | ||
| + | |||
| + | ?> | ||
| + | |||
| + | </code> | ||
| + | \\ | ||
| + | |||
| + | At the output of the platform just the iOS version is appended. With a smartphone or tablet running iOS 5 the output changes from e.g. **iOS** to **iOS_V5**. | ||
| + | |||
| + | |||
| + | Please check with the iPod and older iOS versions. | ||
| + | |||
| + | \\ | ||
| + | |||
| + | ==== Version 1.1 ==== | ||
| + | |||
| + | It is tested against iOS versions greater than 5. | ||
| + | |||
| + | Use within the CMS e.g.: | ||
| + | |||
| + | <!--if:platform:iOS-->iOS Version x - 5<!--/if--> | ||
| + | <!--if:platform:iOS_V6-->iOS Version6<!--/if--> | ||
| + | |||
| + | \\ | ||
| + | **Simple script:** derived from -> [[http://stackoverflow.com/questions/7768324/detect-ios-version-with-php|Detect iOS version with PHP]] | ||
| + | |||
| + | **File:** template/inc_script/**frontend_init**/rt_iOS_OS_user_agent.php | ||
| + | |||
| + | <code php |h rt_iOS_OS_user_agent.php |h> | ||
| + | <?php | ||
| + | /* | ||
| + | ******************************************************************* | ||
| + | * 08.11.2012 KH: Extract the OS from the User-Agent for iOS devices | ||
| + | * V1.1 | ||
| + | * This solution can be queried with the built in if statements. -> iOS, iOS_V6 | ||
| + | *Enhanced V1.1: Only if iOS V6 is used, the if statement is extended. | ||
| + | * | ||
| + | * | ||
| + | * In CMS e.g.: | ||
| + | * <!--if:platform:iOS-->iOS Version x - 5<!--/if--> | ||
| + | * <!--if:platform:iOS_V6-->iOS Version6<!--/if--> | ||
| + | * | ||
| + | * File: template/inc_script/frontend_init/rt_iOS_OS_user_agent.php | ||
| + | * | ||
| + | ********************************************************************/ | ||
| + | |||
| + | // ------------------------------------------------------------------------------------------- | ||
| + | // obligate check for phpwcms constants | ||
| + | if (!defined('PHPWCMS_ROOT')) {die("You Cannot Access This Script Directly, Have a Nice Day.");} | ||
| + | // ------------------------------------------------------------------------------------------- | ||
| + | |||
| + | // Example USER-AGENT iOS | ||
| + | // -------------------------------------------------------- | ||
| + | // Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5 | ||
| + | // Mozilla/5.0 (iPad; U; CPU OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5 | ||
| + | // -------------------------------------------------------- | ||
| + | |||
| + | if ($GLOBALS['phpwcms']['USER_AGENT']['platform'] == 'iOS') { | ||
| + | |||
| + | $os_vers = preg_replace("/(.*) OS ([0-9]*)_(.*)/","$2", $_SERVER['HTTP_USER_AGENT']); | ||
| + | |||
| + | if (((int) $os_vers) == $os_vers) // Integer ? | ||
| + | if ($os_vers > 5) | ||
| + | $GLOBALS['phpwcms']['USER_AGENT']['platform'] .= '_V6'; | ||
| + | } | ||
| + | |||
| + | ?> | ||
| + | |||
| + | </code> | ||
| + | \\ | ||
| + | |||
| + | |||
| + | If iOS6 is in use we simply appended _V6. (**iOS** -> **iOS_V6**) to the output. All of the lower iOS versions have no control. | ||
| + | |||
| + | Please check with the iPod and older iOS versions. | ||
| + | |||
| + | \\ | ||
| + | |||