phpcms修改成手机pc自适应的方法-创新互联-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

phpcms修改成手机pc自适应的方法-创新互联

这篇文章主要介绍phpcms修改成手机pc自适应的方法,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

成都创新互联公司成立与2013年,是专业互联网技术服务公司,拥有项目成都做网站、成都网站制作网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元单县做网站,已为上家服务,为单县各地企业和个人服务,联系电话:13518219792

第一步 添加扩展函数 找到文件并且打开  /phpcms/libs/functions/extention.func.php 添加如下代码:

//判断设备  返回bool
function is_mobile() { 
    $user_agent = $_SERVER['HTTP_USER_AGENT']; 
    $mobile_agents = Array("240x320","acer","acoon","acs-","abacho","ahong","airness","alcatel","amoi","android","anywhereyougo.com","applewebkit/525","applewebkit/532","asus","audio","au-mic","avantogo","becker","benq","bilbo","bird","blackberry","blazer","bleu","cdm-","compal","coolpad","danger","dbtel","dopod","elaine","eric","etouch","fly ","fly_","fly-","go.web","goodaccess","gradiente","grundig","haier","hedy","hitachi","htc","huawei","hutchison","inno","ipad","ipaq","ipod","jbrowser","kddi","kgt","kwc","lenovo","lg ","lg2","lg3","lg4","lg5","lg7","lg8","lg9","lg-","lge-","lge9","longcos","maemo","mercator","meridian","micromax","midp","mini","mitsu","mmm","mmp","mobi","mot-","moto","nec-","netfront","newgen","nexian","nf-browser","nintendo","nitro","nokia","nook","novarra","obigo","palm","panasonic","pantech","philips","phone","pg-","playstation","pocket","pt-","qc-","qtek","rover","sagem","sama","samu","sanyo","samsung","sch-","scooter","sec-","sendo","sgh-","sharp","siemens","sie-","softbank","sony","spice","sprint","spv","symbian","tablet","talkabout","tcl-","teleca","telit","tianyu","tim-","toshiba","tsm","up.browser","utec","utstar","verykool","virgin","vk-","voda","voxtel","vx","wap","wellco","wig browser","wii","windows ce","wireless","xda","xde","zte"); 
    $is_mobile = false; 
    foreach ($mobile_agents as $device) { 
        if (stristr($user_agent, $device)) { 
            $is_mobile = true; 
            break; 
        } 
    } 
    return $is_mobile; 
}

第二步 找到首页函数文件控制器,添加如下代码:

在$id = intval($_GET['id']);后面添加

$is_mobile = is_mobile(); //bool 
        //如果是手持设备 跳转手机页面 伪静态网址链接,自行定义
        if(!$is_mobile){

            $url = APP_PATH.'content-'.$catid.'-'.$id.'-1.html';
            echo "";
            exit;
        }

第三步 找到正文页函数文件控制器页面,添加如下代码:

if(!$catid || !$id) showmessage(L('information_does_not_exist'),'blank');后面添加

$is_mobile = is_mobile(); //bool 
        //如果是手持设备 跳转手机页面 
        if($is_mobile){
            switch ($catid) {
                case '6':
                    $typeid = '9';
                    break;
                case '7':
                    $typeid = '14';
                    break;
                // 。。。。 自行添加 参考图一

                default:
                    //code
                    break;
            }

            $url = 'http://m.lanrenmb.com/index.php?a=show&catid='.$catid.'&typeid='.$typeid.'&id='.$id;
            echo "";
            exit;
        }

第四步:首页进行自适应调整就可以了。

 

以上是phpcms修改成手机pc自适应的方法的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联成都网站设计公司行业资讯频道!

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


当前题目:phpcms修改成手机pc自适应的方法-创新互联
URL链接:http://kswsj.cn/article/hsigi.html

其他资讯