判断移动设备 并展示不同模板内容

#1 xoYu

目前能想到的是launch扩展点。
有没有人做过 给个思路。
感谢。

2014-04-23 11:56:27

#2 skyzong

我的做法是弄个函数:
function is_mobile(){ 

    // 判断是否是手机浏览器
    $regex_match="/(nokia|iphone|android|motorola|^mot-|softbank|foma|docomo|kddi|up.browser|up.link|";
    $regex_match.="htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|";
    $regex_match.="blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|";     
    $regex_match.="symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte-|longcos|pantech|gionee|^sie-|portalmmm|";
    $regex_match.="jigs browser|hiptop|^ucweb|^benq|haier|^lct|operas*mobi|opera*mini|320x320|240x320|176x220";
    $regex_match.=")/i";         
    return isset($_SERVER[HTTP_X_WAP_PROFILE]) or isset($_SERVER[HTTP_PROFILE]) or preg_match($regex_match, strtolower($_SERVER[HTTP_USER_AGENT]));
}
function is_wx(){ //微信浏览器
  $userAgent = $_SERVER['HTTP_USER_AGENT'];
  if(strpos($userAgent,"MicroMessenger")){
      return true;
  }else{
      return false;
  }
}

2014-04-23 12:40:45

#3 xoYu

skyzong 发表于 2014-4-23 12:40
我的做法是弄个函数:
感谢回复
有个更好用的开源类 Mobile_Detect.php

你执行流程是怎样的 大概说说。

2014-04-23 13:04:16

#4 xoYu

完整的想法是:
手机等移动设备访问 直接展示对应模板内容。pc访问无影响。
2个情况
一个是用户没有选择 自动选择访问wap站
第二种是用户发现wap站不爽 手动选择pc站。

目前能想到的是launch扩展点。
有没有人做过 给个思路。
感谢。

2014-04-23 13:39:08