快看CMS使用手册

快看CMS使用手册


2.9 任意pc模版增加默认wap模版开关教程

<p>打开模版目录下的header.php文件 在文件最底添加如下代码:</p> <pre><code class="language-php">&lt;?php if ($xtcms_pc==1){ ?&gt; &lt;script&gt; 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&gt;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}}}}; &lt;/script&gt; &lt;?php if ($_GET['play']!=""){ $cc="play.php?play="; $dd="bplay.php?play="; $yugao=explode('.html',$_GET['play']); for($k=0;$k&lt;count($yugao);$k++){ if ($k&gt;0){ $tiaourl=$cc.$_GET['play']; } else{ $tiaourl=$dd.$_GET['play']; } } } ?&gt; &lt;script type="text/javascript"&gt;uaredirect("&lt;?php echo $xtcms_domain;?&gt;wap/&lt;?php echo $tiaourl;?&gt;");&lt;/script&gt; &lt;?php } ?&gt;</code></pre> <p>如图所示: <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/fa9688cafdfd969eb22b9ebd4737ecb4?showdoc=.jpg" alt="" /></p> <p>然后保存,进入网站后台,开启wap模版 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/e9409032e7f1475c818ebfa351d786ef?showdoc=.jpg" alt="" /></p> <p>然后清空两处缓存,“pc静态首页缓存”和“wap静态首页缓存” <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/b76a7b9b259f66211facbe6a0560c796?showdoc=.jpg" alt="" /></p>

页面列表

ITEM_HTML