NAVIGATION
This is an old revision of the document!
Better translate
Since the release of R429 in the template can be made distinctions with IF statements, due to the values of the user agent.
A small test script which reads out the values of the user agent. The results thereof are illustrated in the various <!--if:XXXX-->Do that<!--/if--> queries.
Please install the php file in the directory /frontend_render/..
The control takes the TAG {IF-UAG} or {IF-UAG:X:Y}. Where X is the distance from the left -and Y specify the distance from the upper edge of the browser for the output.
E.g.:
The TAG should be placed near the beginning or end outside of the outer div container.
In the php-file, you can edit the IF statements to your own ideas. In this first overview all possible IF statements are included with simple values. The negative statements are not entered.
conf.inc.php:
$phpwcms['render_device'] = 1; // allow user agent specific rendering templates <!--if:mobile-->DoMobile<!--/if--><!--!if:mobile-->DoNotMobile<!--/!if--><!--!if:default-->Default<!--/!if-->
<!--if:XXXX-->....<!--/if--> oder die Nagation: <!--!if:XXXX-->....<!--/!if-->
mobile
<!--if:mobile--> - All Mobile<br> <!--/if-->
desktop
<!--if:desktop--> - All Desktop<br><!--/if-->
platform: WinPhone, WinCE, Win, iOS, Mac, GoogleTV, Android, BlackBerry, WebOS, Linux, Unix, Symbian, Other
<!--if:platform:win--> - Platform Win PC<br> <!--/if--> <!--if:platform:mac--> - Platform Mac PC<br> <!--/if--> <!--if:platform:win,mac-->- Platform Win und Mac PC<br> <!--/if-->
device: Default, Other, Smartphone, Tablet, Desktop, TV
<!--if:device:Default--> - Device Default<br> <!--/if--> <!--if:device:Smartphonet-->- Device Smartphone<br> <!--/if--> <!--if:device:Tablet--> - Device Tablet<br> <!--/if--> <!--if:device:Desktop--> - Device Desktop<br> <!--/if--> <!--if:device:TV--> - Device TV<br> <!--/if-->
browser: Other, Firefox, Chrome, Safari, IE, IEMobile, Opera, Mozilla
<!--if:browser:Other--> - Browser Other<br> <!--/if--> <!--if:browser:Firefox--> - Browser Firefox<br> <!--/if--> <!--if:browser:Chrome--> - Browser Chrome<br> <!--/if--> <!--if:browser: Safari--> - Browser Safari<br> <!--/if--> <!--if:browser: IE--> - Browser IE<br> <!--/if--> <!--if:browser: IEMobile-->- Browser IEMobile<br><!--/if--> <!--if:browser: Opera--> - Browser Opera<br> <!--/if--> <!--if:browser: Mozilla--> - Browser Safari<br> <!--/if-->
engine: Gecko, Other, WebKit, Opera, KHTML, IE
<!--if:engine:Gecko--> - Engine Gecko<br> <!--/if--> <!--if:engine:Other--> - Engine Other<br> <!--/if--> <!--if:engine:WebKit--> - Engine WebKit<br><!--/if--> <!--if:engine:Opera--> - Engine Opera<br> <!--/if--> <!--if:engine:KHTML--> - Engine KHTML<br> <!--/if--> <!--if:engine:IE--> - Engine IE<br> <!--/if-->
version
<!--if:version:531--> - Version No 531<br><!--/if-->
default
<!--!if:default--> - Not Default<br><!--/!if-->
Very simple method:
The values of the user agent read directly:
dumpVar(phpwcms_getUserAgent());
Comfortable Script:
File: template/inc_script/frontend_render/rt_test_if_user_agent.php
<?php /* ******************************************************************* * Test User-Agent with if statement since r429 * 23.02.2012 KH * * TAG: {IF-UAG} or {IF-UAG:X:Y} with absolute X/Y output position * ********************************************************************/ // ---------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ---------------------------------------------------------------- if (strpos($content['all'], '{IF-UAG') !== false) { $_if = '<b>IF-Statement</b><br>'.LF; // ************************************************************************* // Geasmmelte IF Abfragen: Editierbarer Bereich // ************************************************************************* // ************************************************************************* // mobile $_if .= ' <!--if:mobile--> - All Mobile<br> <!--/if--> '; // desktop $_if .= ' <!--if:desktop--> - All Desktop<br><!--/if--> '; // platform: WinPhone, WinCE, Win, iOS, Mac, GoogleTV, Android, BlackBerry, WebOS, Linux, Unix, Symbian, Other $_if .= ' <!--if:platform:win--> - Platform Win PC<br> <!--/if--> <!--if:platform:mac--> - Platform Mac PC<br> <!--/if--> <!--if:platform:win,mac-->- Platform Win und Mac PC<br> <!--/if--> '; // device: Default, Other, Smartphone, Tablet, Desktop, TV $_if .= ' <!--if:device:Default--> - Device Default<br> <!--/if--> <!--if:device:Smartphonet-->- Device Smartphone<br> <!--/if--> <!--if:device:Tablet--> - Device Tablet<br> <!--/if--> <!--if:device:Desktop--> - Device Desktop<br> <!--/if--> <!--if:device:TV--> - Device TV<br> <!--/if--> '; // browser: Other, Firefox, Chrome, Safari, IE, IEMobile, Opera, Mozilla $_if .= ' <!--if:browser:Other--> - Browser Other<br> <!--/if--> <!--if:browser:Firefox--> - Browser Firefox<br> <!--/if--> <!--if:browser:Chrome--> - Browser Chrome<br> <!--/if--> <!--if:browser: Safari--> - Browser Safari<br> <!--/if--> <!--if:browser: IE--> - Browser IE<br> <!--/if--> <!--if:browser: IEMobile-->- Browser IEMobile<br><!--/if--> <!--if:browser: Opera--> - Browser Opera<br> <!--/if--> <!--if:browser: Mozilla--> - Browser Safari<br> <!--/if--> '; // engine: Gecko, Other, WebKit, Opera, KHTML, IE $_if .= ' <!--if:engine:Gecko--> - Engine Gecko<br> <!--/if--> <!--if:engine:Other--> - Engine Other<br> <!--/if--> <!--if:engine:WebKit--> - Engine WebKit<br><!--/if--> <!--if:engine:Opera--> - Engine Opera<br> <!--/if--> <!--if:engine:KHTML--> - Engine KHTML<br> <!--/if--> <!--if:engine:IE--> - Engine IE<br> <!--/if--> '; // version $_if .= ' <!--if:version:531--> - Version No 531<br><!--/if--> '; // default $_if .= ' <!--!if:default--> - Not Default<br><!--/!if--> '; // ************************************************************************* // ************************************************************************* // ----------------------------------------------------- // Fenster-Ausgabeposition festlegen: {IF-UAG:X:Y} // ----------------------------------------------------- $_left = '200px'; // X px $_top = '10px'; // Y px preg_match('/\{IF-UAG:(.*?):(.*?)\}/', $content['all'], $_matches); if (isset($_matches[1])) $_left = $_matches[1].'px'; // x Position if (isset($_matches[2])) $_top = $_matches[2].'px'; // y Position // ----------------------------------------------------- // User Agent abholen // ----------------------------------------------------- //dumpVar(phpwcms_getUserAgent()); $_userAgent = phpwcms_getUserAgent(); // ----------------------------------------------------- // Ausgabeformat festlegen // ----------------------------------------------------- $_pos_all = '<div style=" display: block; position: absolute; top: '.$_top.'; left: '.$_left.'; overflow: auto; z-index: 8000; background-color:#c4f2e2; border: 1px solid blue; text-align: left;"> '; $_pos_uAg = '<div style=" display: block; width: 160px; float: left; background-color:#c4f2c8; text-align: left; border-right: 1px solid #aaa; padding: 4px;"> '; $_pos_if = '<div style=" display: block; width: 200px; float: left; background-color:#c4f2e2; text-align: left; padding: 4px;"> '; // ----------------------------------------------------- // Output User-Agent // ----------------------------------------------------- $_uAg_Outp = '<b>User-Agent</b><br>'.LF; foreach ($_userAgent as $_key=>$_value) { $_uAg_Outp .= '<div style="float: left; width:65px;">['.$_key.'] </div><div> => '.$_value.'</div>'.LF; } $_uAg_Outp .= '<div style="clear: both;"></div>'.LF; $content['all'] = preg_replace('/\{IF-UAG\}/', $_pos_all.$_pos_uAg.$_uAg_Outp.'</div>'.$_pos_if.$_if.'</div></div>', $content['all'] ); $content['all'] = preg_replace('/\{IF-UAG:.*?:.*?\}/', $_pos_all.$_pos_uAg.$_uAg_Outp.'</div>'.$_pos_if.$_if.'</div></div>', $content['all'] ); } ?>
Use within the CMS e.g.:
<!--if:platform:iOS_V3-->iOS Version3<!--/if--> <!--if:platform:iOS_V4-->iOS Version4<!--/if-->
Simple script: derived from → Detect iOS version with PHP
File: template/inc_script/frontend_init/rt_iOS_OS_user_agent.php
<?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; } ?>
An die Ausgabe der Plattform wird einfach die iOS-Version angehängt, aus iOS bei einem Smartphone oder Tablet wird z.B. iOS_V5.
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.