This is an old revision of the document!


User-Agent

FIXME 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.:

  • {IF-UAG} (X/Y -Values ​​for the position in the script) .
  • {IF-UAG:200:25} (200px in X -and25px in Y-direction).


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.


Condition:

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-->


Application:

<!--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-->


Output Examples:

Desktop:

Tablets:

Smartphones:


PHP Script:

*Very simple method:
The values ​​of the user agent read directly: <code php>dumpVar(phpwcms_getUserAgent());</code>
Comfortable Script: File: template/inc_script/frontend_render/rt_test_if_user_agent.php <code php |h rt_test_if_user_agent.php |h> <?php —————————————————————- 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'] ); } ?> </code>

english/other-enhancements/tools/user-agent.1330043251.txt.gz · Last modified: 2018/06/03 18:08 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0