请教phpcms手机端详细页连接问题

时间:2022-09-19 15:04:18
498030816目前网站pc端正常,pc全站生成的静态页,移动端是伪静态,移动端主页正常,但访问移动详细页就跳转到PC端了,我还是想让它使用移动的详细页模板,不知道应该怎么解决?

2 个解决方案

#1


我是用这种方法做的,红色部分没有设置因为我不知道在哪里设置。我网站是: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("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>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.,

#2


谁帮我解决下phpcms移动网站的问题呢?

#1


我是用这种方法做的,红色部分没有设置因为我不知道在哪里设置。我网站是: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("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>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.,

#2


谁帮我解决下phpcms移动网站的问题呢?