当前位置:网站首页>Phpcms V9 mobile phone access computer station one-to-one jump to the corresponding mobile phone station page plug-in

Phpcms V9 mobile phone access computer station one-to-one jump to the corresponding mobile phone station page plug-in

2022-06-26 09:02:00 CMS applet plug-in [official]

There are many jump codes on the Internet , Some jump to different templates through the controller , Some are through js Jump , But there is a characteristic that it can not be realized ,pc and wap One to one jump of the page , It's a hole , I have been trying to solve this problem , I didn't think of a good method until today :

First of all : First, introduce a local site in the public header api file :jumpwap.php

 

  1. <script language="JavaScript" src="{APP_PATH}api.php?op=jumpwap&id={$id}&catid={$catid}&page={$page}"></script> 

Parametric analysis :
   id Represents the id, The list page and the first page are empty
   catid The column id, If it is blank, it means the home page
    page Pagination , If pc The paging of the mobile station is inconsistent with that of the mobile station , It is recommended to remove this parameter , Otherwise, it may cause paging errors

The second part : In the head head Add inside js Code , It is best to follow the first step of the code ,

 

 

  1. <script type="text/javascript"> 
  2.     var userAgentInfo = navigator.userAgent; 
  3.     var wapurl = $('meta[name="wapurl"]').attr("content"); 
  4.     if  (userAgentInfo.indexOf("Android") > 0 || userAgentInfo.indexOf("iPhone") > 0 || userAgentInfo.indexOf("SymbianOS") > 0 || userAgentInfo.indexOf("Windows Phone") > 0 || userAgentInfo.indexOf("iPod") > 0 || userAgentInfo.indexOf("iPad") > 0)  
  5.     { 
  6.         if(wapurl){ 
  7.              window.location.href = wapurl; 
  8.         }else
  9.             window.location.href = "http://m.pweb123.com/index.php"
  10.         } 
  11.          
  12.     } 
  13. </script> 

The third step : Development jumpwap.php file
Part of the code :


In this way, you can realize the one-to-one jump of the mobile computer website page , Whether static or not, jump can be realized ,

To refuse to reach out to the party , The code is not open source for the time being , If you think it works for you , You can reward me , It doesn't matter how much , Respect the fruits of labor , It's not easy , Understand more !

 

原网站

版权声明
本文为[CMS applet plug-in [official]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260838407245.html