phpcms设置双模板 手机端和pc端 phpcms自定义手机端模板 phpcms手机端模板设置

文件下载链接

https://download.csdn.net/download/qq_39161501/11721012

 

\www\phpcms\modules\content\index.php 

可直接下载文件,覆盖本地文件index.php文件

 

\www\phpcms\templates\default   

新建content_m手机端模板文件夹

 

pc模板页面加入代码

\www\phpcms\templates\default \content

 <script>
    if(/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
        window.location = "/index.php"; 
    }
</script> 

完成!

 

 

手动修改

\www\phpcms\modules\content\index.php  设置手机端

第一处:第31行的 include template('content','index',$default_style);
第二处:第203行 include template('content',$template);
第三处:第265行 include template('content',$template);
第四处:第278行 include template('content',$template);

 

替换为该代码

/*判断客户端*/
		if(substr($_SERVER['SERVER_NAME'], 0,1) == 'm'){
			include template('content_m','index',$default_style);
		}elseif(stristr($_SERVER['HTTP_VIA'],"wap")){// 先检查是否为wap代理,准确度高
			include template('content_m','index',$default_style);
		}elseif(strpos(strtoupper($_SERVER['HTTP_ACCEPT']),"VND.WAP.WML") > 0){// 检查浏览器是否接受 WML.
			include template('content_m','index',$default_style);
		}elseif(preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'])){//检查USER_AGENT
			include template('content_m','index',$default_style); 	
		}else{
			include template('content','index',$default_style);
		}

 

pc模板页面加入代码

\www\phpcms\templates\default \content

 <script>
    if(/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
        window.location = "/index.php"; 
    }
</script> 

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值