最近项目要上线 , 发现平板使用的是pc版的模板 , discuz在手机和PC上有两套模板 , 平板默认使用pc版的模板.
修改代码:
discuz/source/function/function_core.php文件下
function checkmobile() {
global $_G;
$mobile = array();
static $touchbrowser_list =array('iphone', 'android', 'phone', 'mobile', 'wap', 'netfront', 'java', 'opera mobi', 'opera mini',
'ucweb', 'windows ce', 'symbian', 'series', 'webos', 'sony', 'blackberry', 'dopod', 'nokia', 'samsung',
'palmsource', 'xda', 'pieplus', 'meizu', 'midp', 'cldc', 'motorola', 'foma', 'docomo', 'up.browser',
'up.link', 'blazer', 'helio', 'hosin', 'huawei', 'novarra', 'coolpad', 'webos', 'techfaith', 'palmsource',
'alcatel', 'amoi', 'ktouch', 'nexian', 'ericsson', 'philips', 'sagem', 'wellcom', 'bunjalloo', 'maui', 'smartphone',
'iemobile', 'spice', 'bird', 'zte-', 'longcos', 'pantech', 'gionee', 'portalmmm', 'jig browser', 'hiptop',
'benq', 'haier', '^lct', '320x320', '240x320', '176x220', 'windows phone',***'ipad'***);
static $wmlbrowser_list = array('cect', 'compal', 'ctl', 'lg', 'nec', 'tcl', 'alcatel', 'ericsson', 'bird', 'daxian', 'dbtel', 'eastcom',
'pantech', 'dopod', 'philips', 'haier', 'konka', 'kejian', 'lenovo', 'benq', 'mot', 'soutec', 'nokia', 'sagem', 'sgh',
'sed', 'capitel', 'panasonic', 'sonyericsson', 'sharp', 'amoi', 'panda', 'zte');
***//static $pad_list = array('ipad');***
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
if(dstrpos($useragent, $pad_list)) {
return false;
}
if(($v = dstrpos($useragent, $touchbrowser_list, true))){
$_G['mobile'] = $v;
return '2';
}
在 $touchbrowser_list 里面添加值: ipad
并将static $pad_list = array(‘ipad’); 注释掉
本文介绍如何修改Discuz源代码以使平板设备正确加载移动版模板而非PC版。通过调整function_core.php中的检查机制,确保了不同设备类型能够访问到对应版本的内容。
1271

被折叠的 条评论
为什么被折叠?



