'm.cmsyou.com'
=>array(
'm'
=>
'wap'
,
'c'
=>
'index'
,
'a'
=>
'init'
,
'data'
=>array(
'GET'
=>array(
'siteid'
=>1))),
第四步:
现在就可以打开m.jinhuajuanke.cn了。显示手机页面。但是在手机上打开www.jinhuajuanke.cn并不会跳转到m.xxx.com.
{pc:wap action="lists" typeid="2" num="2" order="id DESC"}
{loop $data $r}
<li>
<p><mip-img src="{$r[thumb]}"></mip-img></p>
<p class="new_title"><a href="{show_url($r[catid],$r[id])}">{$r[title]}</a></p>
</li>
{/loop}
{/pc}
第五步:
<meta http-equiv="mobile-agent" content="format=xhtml;url=http://m.jinhuajuanke.cn/">
<script type="text/javascript">
if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?wap")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="http://m.jinhuajuanke.cn";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}
</script>
<script type="text/javascript">
if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?wap")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="http://m.wzbsny.com/index.php?a=page&typeid={getPageTitle($catid)}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}
</script>
在PC内容页添加js
<script type="text/javascript">
if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?wap")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="http://m.wzbsny.com/index.php?&a=show&catid={$catid}&typeid={getPageTitle($catid)}&id={$id}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}
</script>
在phpcms/libs/functions/extention.func.php中添加自定义函数
function getTypeid($catid){
pc_base::load_model('wap_type_model');
$page_db = new wap_type_model;
$arr = $page_db->get_one(array('cat'=>$catid),'typeid');
//返回数据
return $arr[typeid];
}
上一篇:jquery经验总结