以下适用于PC跳转到ectouch手机版的写法。其他手机端的方法类似。
修改文件 includes/lib_main.php 增加以下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | /** * <a href="http://www.uuecs.com/" target="_blank" title="ecshop"><strong class="keylink">ecshop</strong></a> 实现其他页面(商品详情页、商品分类页、<a href="http://www.uuecs.com/tag-tuangou.html" target="_blank" title="团购"><strong class="keylink">团购</strong></a>页、优惠活动页、积分商城) * 判断如果是智能<a href="http://www.uuecs.com/shouji/" target="_blank" title="手机"><strong class="keylink">手机</strong></a>访问的话 跳转到<a href="http://www.uuecs.com/shouji" target="_blank" title="Ectouch"><strong class="keylink">Ectouch</strong></a>1.0<a href="http://www.uuecs.com/shouji/" target="_blank" title="手机"><strong class="keylink">手机</strong></a>版对应页面 方法 * * @access public */ function pc_to_mobile() { //判断是否是<a href="http://www.uuecs.com/shouji/" target="_blank" title="手机"><strong class="keylink">手机</strong></a>访问 $is_mobile = false; $ua = strtolower ( $_SERVER [ 'HTTP_USER_AGENT' ]); $uachar = "/(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile)/i" ; if (( $ua == '' || preg_match( $uachar , $ua ))&& ! strpos ( strtolower ( $_SERVER [ 'REQUEST_URI' ]), 'wap' )) { $is_mobile = true; } /* 判断是否重写,取得文件名 */ $cur_url = basename (PHP_SELF); if ( intval ( $GLOBALS [ '_CFG' ][ 'rewrite' ])){ $filename = strpos ( $cur_url , '-' ) ? substr ( $cur_url , 0, strpos ( $cur_url , '-' )) : substr ( $cur_url , 0, -4); } else { $filename = substr ( $cur_url , 0, -4); } if ( $is_mobile ){ /* * 如果你绑定了手机版域名 http://www.uuecs.com/mobile 为 http://m.abc.com * 那么 $mobile_url = http://m.uuecs.com */ $mobile_url = $GLOBALS [ 'ecs' ]->url(). 'mobile' ; /* 根据文件名分别处理中间的部分 */ if ( $filename != 'index' ) { /* 处理有分类的 */ if (in_array( $filename , array ( 'category' , 'goods' , 'brand' ))) { /* 商品分类或商品 */ if ( 'category' == $filename || 'goods' == $filename || 'brand' == $filename ) { $Loaction = $mobile_url . '/?c=' . $filename . '&a=index&' . $_SERVER [ "QUERY_STRING" ]; } } /* 处理无分类的 */ else { /* <a href="http://www.uuecs.com/tag-tuangou.html" target="_blank" title="团购"><strong class="keylink">团购</strong></a> */ if ( 'group_buy' == $filename ) { if (! empty ( $_GET [ 'id' ])){ $Loaction = $mobile_url . '/?c=groupbuy&a=info&id=' . $_GET [ 'id' ]; } else { $Loaction = $mobile_url . '/?c=groupbuy' ; } } /* 拍卖 */ elseif ( 'auction' == $filename ) { if (! empty ( $_GET [ 'id' ])){ $Loaction = $mobile_url . '/?c=auction&a=info&id=' . $_GET [ 'id' ]; } else { $Loaction = $mobile_url . '/?c=auction' ; } } /* 夺宝 */ elseif ( 'snatch' == $filename ) { if (! empty ( $_GET [ 'id' ])){ $Loaction = $mobile_url . '/?c=snatch&a=info&id=' . $_GET [ 'id' ]; } else { $Loaction = $mobile_url . '/?c=snatch' ; } } /* 批发 */ elseif ( 'wholesale' == $filename ) { if (! empty ( $_GET [ 'id' ])){ $Loaction = $mobile_url . '/?c=wholesale&a=info&id=' . $_GET [ 'id' ]; } else { $Loaction = $mobile_url . '/?c=wholesale' ; } } /* 积分兑换 */ elseif ( 'exchange' == $filename ) { if (! empty ( $_GET [ 'id' ])){ $Loaction = $mobile_url . '/?c=exchange&a=exchange_goods&gid=' . $_GET [ 'id' ]; } else { $Loaction = $mobile_url . '/?c=exchange' ; } } /* 优惠活动 */ elseif ( 'activity' == $filename ) { $Loaction = $mobile_url . '/?c=activity' ; } } /* <a href="http://www.uuecs.com/" target="_blank" title="ecshop"><strong class="keylink">ecshop</strong></a>跳转到手机对应页面 */ if (! empty ( $Loaction )){ ecs_header( "Location: $Loaction" ); exit ; } } } } |
随后在 includes/init.php 增加到最底部 ?>前即可。
1 | pc_to_mobile(); |