帝國CMS 全站電腦端自動切換到手機端的動態/靜態程式碼

ECMS 自動跳轉手機端程式碼

帝國CMS 7.2 版推出完善的多重訪問終端功能,讓各種行動訪問端的製作方便許多。7.5 版多重訪問端再升級:支援在主端後台更新產生各訪問端的靜態頁面,多重訪問端採靜態模式時更好用。

1、頁面頭部。JS 程式碼放在 body 前面,加上以下 HTML 原始碼

<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(ipod|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i)))
{window.location="'http://m.aijun.org/'";}}}
catch(err)
{
}</script>
<script data-fixed="true">
  !function(){
    function params(u, p){
      var m = new RegExp("(?:&|/?)"+p+"=([^&$]+)").exec(u);
      return m ? m[1] : '';
    }
    if(/iphone|ios|android|ipod/i.test(navigator.userAgent.toLowerCase()) == true && params(location.search, "from") != "mobile"){
      location.href = 'http://m.aijun.org/';
    }
  }();
</script>

2、列表頁

動態頁:http://m.aijun.org/e/action/ListInfo/?classid=[!--self.classid--]
靜態頁:http://m.aijun.org<?$r['classid']=$GLOBALS[navclassid];$classurl=sys_ReturnBqClassname($r,9);echo $classurl;?>

3、內容頁

動態頁:http://m.aijun.org/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]
靜態頁:http://m.aijun.org[!--titleurl--]

分成動態與靜態頁面兩種,可自行把 aijun.org 換成自己的子網域。

發表評論

評論 暫無評論

文章目錄