Die Liste, welche UserAgents für Contao "mobile devices" sind, steht in der Datei system/config/agents.php:
PHP-Code:
$GLOBALS['TL_CONFIG']['os'] = array
(
'Macintosh' => array('os'=>'mac', 'mobile'=>false),
'Windows CE' => array('os'=>'win-ce', 'mobile'=>true),
'Windows Phone' => array('os'=>'win-ce', 'mobile'=>true),
'Windows' => array('os'=>'win', 'mobile'=>false),
'iPad' => array('os'=>'ios', 'mobile'=>false),
'iPhone' => array('os'=>'ios', 'mobile'=>true),
'iPod' => array('os'=>'ios', 'mobile'=>true),
'Android' => array('os'=>'android', 'mobile'=>true),
'Blackberry' => array('os'=>'blackberry', 'mobile'=>true),
'Symbian' => array('os'=>'symbian', 'mobile'=>true),
'WebOS' => array('os'=>'webos', 'mobile'=>true),
'Linux' => array('os'=>'unix', 'mobile'=>false),
'FreeBSD' => array('os'=>'unix', 'mobile'=>false),
'OpenBSD' => array('os'=>'unix', 'mobile'=>false),
'NetBSD' => array('os'=>'unix', 'mobile'=>false),
);
Die Erkennung läuft dann in system/modules/core/library/Contao/Environment.php:
PHP-Code:
protected static function agent() {
[...]
foreach ($GLOBALS['TL_CONFIG']['os'] as $k=>$v)
{
if (stripos($ua, $k) !== false)
{
$os = $v['os'];
$mobile = $v['mobile'];
break;
}
}
Contao geht also nicht nach Auflösung oder Browser-Features (wie Touch Events), sondern nach dem laufenden Betriebssystem.
Daher müsste eigentlich das Nexus 7 als Android und somit als "mobile device" erkannt werden, merkwürdig...
(Da dessen UserAgent "Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03D) [...]" das Wort "Android" enthält und die Schleife das Array nach dem ersten Treffer abbricht)
Um eigene Agents als "mobile device" zu deklarieren, müsste es ausreichen, wenn du der Variable $GLOBALS['TL_CONFIG']['os'] einen Wert hinzufügst - am Besten an den Anfang des Arrays.
Lesezeichen