帝國CMS開啟多終端訪問時訪問電腦端以及手機端自動跳轉(zhuǎn)含動態(tài)頁和靜態(tài)頁代碼

[重要通告]如您遇疑難雜癥,本站支持知識付費業(yè)務(wù),掃右邊二維碼加博主微信,可節(jié)省您寶貴時間哦!

最近折騰了一個帝國的站,真的是各種的折騰,倒騰的都累了,今天好不容易搞定了手機以及PC站,但是不咋跳轉(zhuǎn),這就尷尬了,倒騰了好久才找到了解決辦法,具體操作如下;

Empire CMS 7.2版本引入了全面的多接入終端功能,使網(wǎng)站更方便地制作多個移動接入終端;版本7.5中的多訪問者升級:支持主端的后臺刷新以生成每個訪問端的靜態(tài)頁面,并且多訪問端在靜態(tài)模式下使用更方便。

首頁頁面頭部

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="https://m.zuowenla.net/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=https://m.zuowenla.net/">

列表頁

動態(tài)頁:https://m.zuowenla.net/e/action/ListInfo/?classid=[!--self.classid--]
靜態(tài)頁:https://m.zuowenla.net<?$r['classid']=$GLOBALS[navclassid];$classurl=sys_ReturnBqClassname($r,9);echo $classurl;?>

內(nèi)容頁

動態(tài)頁:https://m.zuowenla.net/e/action/ListInfo/?classid=[!--self.classid--]
靜態(tài)頁:https://m.zuowenla.net<?$r['classid']=$GLOBALS[navclassid];$classurl=sys_ReturnBqClassname($r,9);echo $classurl;?>

分成動態(tài)與靜態(tài)頁面,可自行選擇更換m.zuowenla.net為自己的子域名哦。

PS:繼續(xù)延伸其他辦法

1、假設(shè)我們有帝國cms 電腦網(wǎng)站www.zuowenla.net,手機網(wǎng)站m.zuowenla.net

現(xiàn)在電腦端手機端都是生成靜態(tài)網(wǎng)站,除了域名不同,靜態(tài)連接地址都是相同的,例如:

www.zuowenla.net/demo/1.html? ? 對應(yīng)? ? m.zuowenla.net/demo/1.html

2、接下來要給電腦網(wǎng)站的首頁、列表頁、內(nèi)容頁的模板添加跳轉(zhuǎn)代碼,方法如下:

js是瀏覽器跳轉(zhuǎn),meta是告訴搜索引擎移動頁面的地址。

1)首頁模板需添加下面代碼

script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="https://m.zuowenla.net/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=https://m.zuowenla.net/">

2)封面頁和列表頁添加下面代碼

<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="https://m.zuowenla.net<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=https://m.zuowenla.net<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>">

3)內(nèi)容頁添加下面代碼

<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="https://m.zuowenla.net[!--titleurl--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=https://m.zuowenla.net[!--titleurl--]">

添加完上面代碼后,帝國cms的電腦網(wǎng)站的每個頁面都可以跳轉(zhuǎn)到手機靜態(tài)網(wǎng)站嘍。 就是這么的完美;(更新于2020年03月05日)

還有第三種方式,方式如下:

第一步:我們新建一個js文件,命名你隨便,路徑也隨便,js代碼如下

function browserRedirect(url) {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
if (bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM){
window.location.replace(url);
}
}

把js命名為 m.js 放到了根目錄下面 然后把下面的代碼復(fù)制到對應(yīng)的模板里面 首頁跳轉(zhuǎn)

<script src='https://www.zuowenla.net/m.js' language='javascript'></script>
<script type="text/javascript">
browserRedirect("https://m.zuowenla.net/");
</script>

封面頁和列表頁跳轉(zhuǎn)

<script src='https://www.zuowenla.net/m.js' language='javascript'></script>
<script type="text/javascript">
browserRedirect("https://m.zuowenla.net/e/public/ClassUrl/?classid=[!--self.classid--]");
</script>

內(nèi)容頁跳轉(zhuǎn)

<script src='https://www.zuowenla.net/m.js' language='javascript'></script>
<script type="text/javascript">
browserRedirect("https://m.zuowenla.net[!--titleurl--]");
</script>

更新于2020年03月06日

問題未解決?付費解決問題加Q或微信 2589053300 (即Q號又微信號)右上方掃一掃可加博主微信

所寫所說,是心之所感,思之所悟,行之所得;文當(dāng)無敷衍,落筆求簡潔。 以所舍,求所獲;有所依,方所成!

支付寶贊助
微信贊助

免責(zé)聲明,若由于商用引起版權(quán)糾紛,一切責(zé)任均由使用者承擔(dān)。

您必須遵守我們的協(xié)議,如您下載該資源,行為將被視為對《免責(zé)聲明》全部內(nèi)容的認可->聯(lián)系老梁投訴資源
LaoLiang.Net部分資源來自互聯(lián)網(wǎng)收集,僅供用于學(xué)習(xí)和交流,請勿用于商業(yè)用途。如有侵權(quán)、不妥之處,請聯(lián)系站長并出示版權(quán)證明以便刪除。 敬請諒解! 侵權(quán)刪帖/違法舉報/投稿等事物聯(lián)系郵箱:service@laoliang.net
意在交流學(xué)習(xí),歡迎贊賞評論,如有謬誤,請聯(lián)系指正;轉(zhuǎn)載請注明出處: » 帝國CMS開啟多終端訪問時訪問電腦端以及手機端自動跳轉(zhuǎn)含動態(tài)頁和靜態(tài)頁代碼

發(fā)表回復(fù)

本站承接,網(wǎng)站推廣(SEM,SEO);軟件安裝與調(diào)試;服務(wù)器或網(wǎng)絡(luò)推薦及配置;APP開發(fā)與維護;網(wǎng)站開發(fā)修改及維護; 各財務(wù)軟件安裝調(diào)試及注冊服務(wù)(金蝶,用友,管家婆,速達,星宇等);同時也有客戶管理系統(tǒng),人力資源,超市POS,醫(yī)藥管理等;

立即查看 了解詳情