当前位置:首页 > 文章 > 帝国CMS > 正文内容

帝国cms电脑网站跳转到手机动态网站和手机静态网站的方法

3年前 (2022-10-21)帝国CMS7414
本文讲解一下帝国cms电脑网站跳转到手机动态网站和手机静态网站的方法。

方法一:帝国pc站跳转到手机静态站

1、假设我们有帝国cms 电脑网站www.zuowenxz.com,手机网站m.zuowenxz.com,手机网站使用帝国cms的多访问端功能制作.现在电脑端和手机端都是生成静态网站,除了域名不同,静态连接地址都是相同的,例如:
www.zuowenxz.com/china/1.html对应 m.zuowenxz.com/china/1.html

2、接下来要给电脑网站的首页、列表页、内容页的模板添加跳转代码,方法如下:
js是浏览器跳转,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="http://m.zuowenxz.com/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zuowenxz.com/">

(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="http://m.zuowenxz.com<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zuowenxz.com<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>">

(3)内容页添加下面代码
<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="http://m.zuowenxz.com[!--titleurl--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zuowenxz.com[!--titleurl--]">

添加完上面代码后,帝国cms的电脑网站的每个页面都可以跳转到手机静态网站了。

但手机静态站是有缺点的,每次我们更新电脑端文章,都要去手机端后台重新生成一下html,比较麻烦,所以我们可以把手机站设置成动态访问,接下来就讲解一下电脑端跳转手机动态站的方法。

方法二:帝国cms电脑网站跳转到手机动态站的方法
1、首先在电脑端的多访问端设置,把手机端设置成强制动态页面模式。这样手机站就是动态了,不用每次都去生成html 。
2、接下来就是给电脑端模板的首页、列表页、内容页添加相依跳转代码,和方法一类似。
js是浏览器跳转,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="http://m.zuowenxz.com/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zuowenxz.com/">

(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="http://m.zuowenxz.com/e/action/ListInfo/?classid=[!--self.classid--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zuowenxz.com/e/action/ListInfo/?classid=[!--self.classid--]">

(3)内容页添加下面代码
<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="http://m.zuowenxz.com/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zuowenxz.com/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]">

添加上面代码后,pc网站就可以跳转到手机端的对应网页了。
注意:使用上面代码时,把代码中的域名改成你自己的域名就可以了。
————————————————
版权声明:本文为CSDN博主「cjava2012」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://oss.blueboss.cn/blueboss/zb_users/upload/2022/10c/21/cb124209512p166

扫描二维码推送至手机访问。

版权声明:本文由蓝博发布,如需转载请注明出处。

本文链接:https://blueboss.cn/p/250.shtml

“帝国cms电脑网站跳转到手机动态网站和手机静态网站的方法” 的相关文章

帝国CMS内容页模板判断字段为空不显示

帝国CMS内容页模板判断字段为空不显示

帝国CMS内容页模板怎么样才能让某一个字段,如果填写了就显示,没有填写就不显示呢?其实方法很简单,下面帝国cms模板网就来告诉大家怎么调用: <?phpif($navinfor[字段名]){?>字段有值时显示的内容,如[!---字段名--]<?}else{?>字段无值时显示...

帝国cms内容页正文附件下载的调用代码

帝国cms内容页正文附件下载的调用代码

帝国cms内容页正文附件下载的调用代码 [e:loop={"select * from phome_enewsfile_1 where classid='$navinfor[classid]' and id='$navinfor[id]' order by id desc",0,24,0,'','...

帝国cms灵动标签实现循环子栏目数据

帝国cms灵动标签实现循环子栏目数据

帝国cms灵动标签实现循环子栏目数据 <?php $bclassid=$GLOBALS[navclassid];//取得本栏目id //取得本栏目下的子栏目 ?> [e:loop={"select classid, classname, classpath from `[!db.pre...

帝国CMS多值字段如何调用多值字段最新增加的一行内容

帝国CMS多值字段如何调用多值字段最新增加的一行内容

帝国cms模板里面的多值字段怎么调用呢? 多值字段调用如下: <?php $morefr=explode('||||||',$navinfor[字段名]); $mfcount=count($morefr); for($mfi=0;$mfi<$mfcount;$mfi++) { $mor...

帝国cms电影模型内容页调用播放器类型

帝国cms电影模型内容页调用播放器类型

一、以图片形式显示 1、在/skin/xin/v/中增加几个播放器的图片 ①图片格式自己定,如:增加了ico的格式,在:系统-系统设置-系统参数设置-文件设置-后台上传文件扩展名-添加ico的图片格式 ②图片的命名:以播放器的ID命名(ID参考:后台-其他-下载模型相关-播放器管理-看播放器对应的I...

帝国CMS专题页面调用当前专题页面地址

帝国CMS专题页面调用当前专题页面地址

当前专题页面地址 <?=$public_r[newsurl]?><?=$class_zr[$GLOBALS[navclassid]][ztpath]?> <?=$public_r[newsurl]?>网站地址 <?=$class_zr[$GLOBALS[n...