简易移动端皮肤自动切换

This page is a translated version of the page Simple mobile skin auto change and the translation is 100% complete.

以下代码片段(添加到 LocalSettings.php)允许检测 iPhone,然后自动将皮肤/主题切换到与 iPhone 兼容的皮肤/主题(在本例中为 WPtouch)。 安装 iPhone 兼容皮肤后,将此代码添加到您的 LocalSettings.php 文件(替换当前的 $wgDefaultSkin 变量)。 如果是 iPhone,这将使默认皮肤为“wptouch”,否则为“vector”。 根据需要进行修改。 如果启用了文件缓存,您可能需要禁用它以防止访问者看到错误的皮肤。

如果用户登录,他们的皮肤首选项会覆盖此设置。

Example code

## 默认皮肤:您可以更改默认皮肤。
## 使用内部符号名称,即'vector'、'monobook':
if (preg_match("/(mobile|webos|opera mini)/i", $_SERVER['HTTP_USER_AGENT'])) {
    $wgDefaultSkin = 'wptouch';
} else {
    $wgDefaultSkin = 'vector';
}


Mobile configuration with Skin:MinervaNeue without using Extension:MobileFrontend

## Default skin: you can change the default skin.
## Use the internal symbolic names, ie 'vector', 'monobook':
if (preg_match("/(mobile|webos|opera mini|android|blackberry|tablet)/i", $_SERVER['HTTP_USER_AGENT'])) {
    $wgDefaultSkin = 'minerva';
} else {
    $wgDefaultSkin = 'vector';
}