请教phpcms手机端详细页连接问题 498030816目前网站pc端正常,pc全站生成的静态页,移动端是伪静态,移动端主页正常,但访问移动详细页就跳转到PC端了,我还是想让它使用移动的详细页模板,不知道应该怎么解决? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我是用这种方法做的,红色部分没有设置因为我不知道在哪里设置。我网站是:http://m.xingyuwang.cn/ 以免复制出错 附上改好的文件 直接下载放到 phpcms/modules/content/目录下就行 第一步:网址解析绑定三个网址:http://www.XX.com、http://m.XX.com、http://XX.com第二步:做网址伪静态栏目伪静态后网址如:http://www.XX.com/list-1-1.html,内容页网址:http://www.XX.com/show-1-1-1.html。对应移动站网址:栏目伪静态后网址如:http://m.XX.com/list-1-1.html,内容页网址:http://m.XX.com/show-1-1-1.html。第三步:修改phpcms/modules/content/index.php。在31行处找到include template('content','index',$default_style);修改为:if(substr($_SERVER['SERVER_NAME'], 0,1) == 'm'){include template('wap','index',$default_style);}else{include template('content','index',$default_style);}分别把include template('content',$template);修改为:if(substr($_SERVER['SERVER_NAME'], 0,1) == 'm'){include template('wap',$template);}else{include template('content',$template);}一共有三处意思是,当域名头部为m时选择 content_m文件夹里的模板,www时选择content文件夹的模板。第四步:把存放模板的文件夹content复制一份,重命名为content_m,里面的模板文件名一样,里面基本文件模板目录名为content_m第五步:在PC板模板加入跳转脚本判断为移动端自动跳转网址脚本写法:首页、单页、栏目页、内容页各自调用单独的头部模板,方便写跳转网址。1、首页跳转的网址写法为:2、单页、栏目页跳转的网址写法为:3、内容页跳转的网址写法为:脚本uaredirect.js的文本为:function uaredirect(f){try{if(document.getElementById("bd")!=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}}}};个人建议脚本尽量放在靠前位置比较好吧,因为加载网页时尽早触发脚本,跳转到移动网页会不会快点呢?第六步:content_m中模板调用的更改手机站和PC站一样的标签调用。由于phpcms把文章的url都固定写死在数据表中.所以,页面中的标签不能在使用{$r[url]},而要改成{str_replace('http://www.','http://m.',$r[url])},意思是,截取url,把http://www.替换成http://m., 谁帮我解决下phpcms移动网站的问题呢? 如何用循环队列来串口通信中的读写缓存呢? 找熟悉Second life web应用程序开发的人帮忙 Rewrite规则求助,已经baidu了几个小时了, PHP序列化熟悉的麻烦进来看下 [源码]天骄天下个人网站系统(三个月倾情打造) 求一个抓取网页的正则 纯html中的播放器问题 紧急求救:使用open-flash-chart做图表时,如何格式化各数值点的啊? mysql 返回Result consisted of more than one row PHPstudy怎么绑定域名外网访问,求助 key value加密 discuz中为啥不能使用判断呢
以免复制出错 附上改好的文件 直接下载放到 phpcms/modules/content/目录下就行
第一步:网址解析绑定三个网址:http://www.XX.com、http://m.XX.com、http://XX.com第二步:做网址伪静态
栏目伪静态后网址如:http://www.XX.com/list-1-1.html,内容页网址:http://www.XX.com/show-1-1-1.html。对应移动站网址:栏目伪静态后网址如:http://m.XX.com/list-1-1.html,内容页网址:http://m.XX.com/show-1-1-1.html。第三步:修改phpcms/modules/content/index.php。在31行处找到include template('content','index',$default_style);修改为:
if(substr($_SERVER['SERVER_NAME'], 0,1) == 'm'){
include template('wap','index',$default_style);
}else{
include template('content','index',$default_style);
}分别把include template('content',$template);修改为:
if(substr($_SERVER['SERVER_NAME'], 0,1) == 'm'){
include template('wap',$template);
}else{
include template('content',$template);
}一共有三处意思是,当域名头部为m时选择 content_m文件夹里的模板,www时选择content文件夹的模板。第四步:把存放模板的文件夹content复制一份,重命名为content_m,里面的模板文件名一样,里面基本文件模板目录名为content_m第五步:在PC板模板加入跳转脚本判断为移动端自动跳转网址脚本写法:
首页、单页、栏目页、内容页各自调用单独的头部模板,方便写跳转网址。1、首页跳转的网址写法为:2、单页、栏目页跳转的网址写法为:3、内容页跳转的网址写法为:脚本uaredirect.js的文本为:function uaredirect(f){try{if(document.getElementById("bd")!=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}}}};个人建议脚本尽量放在靠前位置比较好吧,因为加载网页时尽早触发脚本,跳转到移动网页会不会快点呢?第六步:content_m中模板调用的更改
手机站和PC站一样的标签调用。由于phpcms把文章的url都固定写死在数据表中.所以,页面中的标签不能在使用{$r[url]},而要改成{str_replace('http://www.','http://m.',$r[url])},意思是,截取url,把http://www.替换成http://m.,