亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

phpcms修改成手機pc自適應的方法

發布時間:2020-08-25 11:19:23 來源:億速云 閱讀:312 作者:小新 欄目:編程語言

這篇文章主要介紹phpcms修改成手機pc自適應的方法,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

第一步 添加擴展函數 找到文件并且打開  /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 "<script>location.href='".$url."'</script>";
            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 "<script>location.href='".$url."'</script>";
            exit;
        }

第四步:首頁進行自適應調整就可以了。

 <script type="text/javascript">

function uaredirect(f){try{if(document.getElementById("bdmark")!=null){return}var b=false;if(arguments[1]){var e=window.location.host;var a=window.location.href;if(isSubdomain(arguments[1],e)==1){f=f+"/#m/"+a;b=true}else{if(isSubdomain(arguments[1],e)==2){f=f+"/#m/"+a;b=true}else{f=a;b=false}}}else{b=true}if(b){var c=window.location.hash;if(!c.match("fromapp")){if((navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i))){location.replace(f)}}}}catch(d){}}function isSubdomain(c,d){this.getdomain=function(f){var e=f.indexOf("://");if(e>0){var h=f.substr(e+3)}else{var h=f}var g=/^www\./;if(g.test(h)){h=h.substr(4)}return h};if(c==d){return 1}else{var c=this.getdomain(c);var b=this.getdomain(d);if(c==b){return 1}else{c=c.replace(".","\\.");var a=new RegExp("\\."+c+"$");if(b.match(a)){return 2}else{return 0}}}};

 </script>

<script type="text/javascript">uaredirect("http://m.lanrenmb.com/");</script>

以上是phpcms修改成手機pc自適應的方法的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

年辖:市辖区| 江门市| 浦东新区| 偃师市| 大埔县| 廉江市| 茌平县| 南丰县| 射阳县| 大庆市| 大化| 湘潭市| 靖州| 东至县| 安塞县| 林甸县| 仪陇县| 广宗县| 蓬莱市| 云梦县| 阿克苏市| 涡阳县| 咸宁市| 湘阴县| 田东县| 北川| 新源县| 民勤县| 亚东县| 余庆县| 大冶市| 田阳县| 孝昌县| 三明市| 溧水县| 西青区| 旅游| 阳山县| 芜湖市| 永清县| 琼结县|