Detailed explanation of how to build a wap website with PHPCMS

*文
Release: 2023-03-19 09:18:01
Original
1858 people have browsed it

PHPCMS How to build a wap website? PHPCMS is more convenient for building PC websites, but it is not very practical for WAP mobile phones. Moreover, the built-in mobile website building does not feel very good, and the template is difficult to control. Now that I have modified it, I personally feel that mobile website building is more convenient. This article introduces how to use PHPCMS to build a wap mobile website. Friends in need can refer to it. I hope to be helpful.

Let me tell you how to use PHPCMS to build a wap mobile website. Please see below for the specific content.

First write the custom function to determine mobile phone access in phpcms/libs/functions/extention.func.php

<?php
/**
 * extention.func.php 用户自定义函数库
 *
 */
//判断是否手机访问
function check_wap()
{
 if (isset($_SERVER[&#39;HTTP_VIA&#39;])) return true;
 if (isset($_SERVER[&#39;HTTP_X_NOKIA_CONNECTION_MODE&#39;])) return true;
 if (isset($_SERVER[&#39;HTTP_X_UP_CALLING_LINE_ID&#39;])) return true;
 if (strpos(strtoupper($_SERVER[&#39;HTTP_ACCEPT&#39;]), "VND.WAP.WML") > 0) {
  // Check whether the browser/gateway says it accepts WML.
  $br = "WML";
 } else {
  $browser = isset($_SERVER[&#39;HTTP_USER_AGENT&#39;]) ? trim($_SERVER[&#39;HTTP_USER_AGENT&#39;]) : &#39;&#39;;
  if (empty($browser)) return true;
  $clientkeywords = array(
   &#39;nokia&#39;, &#39;sony&#39;, &#39;ericsson&#39;, &#39;mot&#39;, &#39;samsung&#39;, &#39;htc&#39;, &#39;sgh&#39;, &#39;lg&#39;, &#39;sharp&#39;, &#39;sie-&#39;
  , &#39;philips&#39;, &#39;panasonic&#39;, &#39;alcatel&#39;, &#39;lenovo&#39;, &#39;iphone&#39;, &#39;ipod&#39;, &#39;blackberry&#39;, &#39;meizu&#39;,
   &#39;android&#39;, &#39;netfront&#39;, &#39;symbian&#39;, &#39;ucweb&#39;, &#39;windowsce&#39;, &#39;palm&#39;, &#39;operamini&#39;,
   &#39;operamobi&#39;, &#39;opera mobi&#39;, &#39;openwave&#39;, &#39;nexusone&#39;, &#39;cldc&#39;, &#39;midp&#39;, &#39;wap&#39;, &#39;mobile&#39;
  );
  if (preg_match("/(" . implode(&#39;|&#39;, $clientkeywords) . ")/i", $browser) && strpos($browser, &#39;ipad&#39;) === false) {
   $br = "WML";
  } else {
   $br = "HTML";
  }
 }
 if ($br == "WML") {
  return TRUE;
 } else {
  return FALSE;
 }
}
?>
Copy after login

Then in phpcms/templates/default template Create a folder in the folder to store the templates of the mobile site

I created a folder called mobile

and then modified
phpcms/templates/modules/content /index.php file

Troublesome point, it is judged when loading the template on the channel page, list page, and content page respectively
For example:

if (check_wap()) {
    include template(&#39;mobile&#39;, $template);
   } else {
    include template(&#39;content&#39;, $template);
   }
}
Copy after login

This way when accessed by mobile phone The template in the mobile folder will be loaded. The name of the template in the mobile folder must be the same as that on the PC.
Of course, there will be problems when generating static pages. The current solution is to use dynamic ones on the mobile phone.
This can be done when calling data

<a href="index.php?m=content&c=index&a=show&catid=25&id={$r[&#39;id&#39;]}">
Copy after login

After all, there are not many columns on the mobile phone.

Related recommendations:

Detailed explanation of how to implement the comment reply and delete function in PHP

Detailed explanation of how PHP uses redis queue to realize automatic confirmation of receipt of e-commerce orders

Detailed explanation of how php7 implements MongoDB fuzzy query

The above is the detailed content of Detailed explanation of how to build a wap website with PHPCMS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template