PHPCMS builds wap mobile website
PHPCMS is more convenient to build PC-side websites, but it is not very practical when it comes to WAP mobile phones. Moreover, the built-in mobile website building is not very good, and the template is difficult to control. Now I modify it, and I personally feel that mobile website building is more convenient
First, write the custom function to determine mobile phone access in phpcms/libs/functions/extention.func.php
<?<span>php </span><span>/*</span><span>* * extention.func.php 用户自定义函数库 * * @copyright (C) 2005-2010 PHPCMS * @license * @lastmodify 2010-10-27 </span><span>*/</span><span>//</span><span>判断是否手机访问</span><span>function</span><span> check_wap() { </span><span>if</span> (<span>isset</span>(<span>$_SERVER</span>['HTTP_VIA'])) <span>return</span><span>true</span><span>; </span><span>if</span> (<span>isset</span>(<span>$_SERVER</span>['HTTP_X_NOKIA_CONNECTION_MODE'])) <span>return</span><span>true</span><span>; </span><span>if</span> (<span>isset</span>(<span>$_SERVER</span>['HTTP_X_UP_CALLING_LINE_ID'])) <span>return</span><span>true</span><span>; </span><span>if</span> (<span>strpos</span>(<span>strtoupper</span>(<span>$_SERVER</span>['HTTP_ACCEPT']), "VND.WAP.WML") > 0<span>) { </span><span>//</span><span> Check whether the browser/gateway says it accepts WML.</span><span>$br</span> = "WML"<span>; } </span><span>else</span><span> { </span><span>$browser</span> = <span>isset</span>(<span>$_SERVER</span>['HTTP_USER_AGENT']) ? <span>trim</span>(<span>$_SERVER</span>['HTTP_USER_AGENT']) : ''<span>; </span><span>if</span> (<span>empty</span>(<span>$browser</span>)) <span>return</span><span>true</span><span>; </span><span>$clientkeywords</span> = <span>array</span><span>( </span>'nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-' , 'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone', 'ipod', 'blackberry', 'meizu', 'android', 'netfront', 'symbian', 'ucweb', 'windowsce', 'palm', 'operamini', 'operamobi', 'opera mobi', 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile'<span> ); </span><span>if</span> (<span>preg_match</span>("/(" . <span>implode</span>('|', <span>$clientkeywords</span>) . ")/i", <span>$browser</span>) && <span>strpos</span>(<span>$browser</span>, 'ipad') === <span>false</span><span>) { </span><span>$br</span> = "WML"<span>; } </span><span>else</span><span> { </span><span>$br</span> = "HTML"<span>; } } </span><span>if</span> (<span>$br</span> == "WML"<span>) { </span><span>return</span><span>TRUE</span><span>; } </span><span>else</span><span> { </span><span>return</span><span>FALSE</span><span>; } } </span>?><br>然后在phpcms/templates/default模版文件夹里建立一个文件夹存放手机站的模版<br>我建立一个叫mobile的文件夹<br>然后修改
phpcms/templates/modules/content/index.php文件<br>麻烦点,分别在频道页,列表页,内容页加载模版时进行判断<br>比如:
<span>if</span><span> (check_wap()) { </span><span><strong>include</strong></span> template('mobile', <span>$template</span><span>); } </span><span>else</span><span> {</span><span><strong>include</strong></span> template('content', <span>$template</span><span>); }<br>这样当用手机访问时会加载mobile文件夹里面的模版,mobile文件夹里面的模版名字要跟PC端的一样。<br>当然,在生成静态页面时会出现问题,目前解决的办法是手机端用动态,<br>调用数据时可以这样</span>
<a href="index.php?m=content&c=index&a=show&catid=25&id={$r['id']}">
After all, there are not many columns on the mobile phone
<span><br></span>
The above introduces PHPCMS to build a wap mobile website, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

WindowsServerBackup is a function that comes with the WindowsServer operating system, designed to help users protect important data and system configurations, and provide complete backup and recovery solutions for small, medium and enterprise-level enterprises. Only users running Server2022 and higher can use this feature. In this article, we will explain how to install, uninstall or reset WindowsServerBackup. How to Reset Windows Server Backup If you are experiencing problems with your server backup, the backup is taking too long, or you are unable to access stored files, then you may consider resetting your Windows Server backup settings. To reset Windows

Understand the meaning of HTTP 301 status code: common application scenarios of web page redirection. With the rapid development of the Internet, people's requirements for web page interaction are becoming higher and higher. In the field of web design, web page redirection is a common and important technology, implemented through the HTTP 301 status code. This article will explore the meaning of HTTP 301 status code and common application scenarios in web page redirection. HTTP301 status code refers to permanent redirect (PermanentRedirect). When the server receives the client's

HTTP Status Code 200: Explore the Meaning and Purpose of Successful Responses HTTP status codes are numeric codes used to indicate the status of a server's response. Among them, status code 200 indicates that the request has been successfully processed by the server. This article will explore the specific meaning and use of HTTP status code 200. First, let us understand the classification of HTTP status codes. Status codes are divided into five categories, namely 1xx, 2xx, 3xx, 4xx and 5xx. Among them, 2xx indicates a successful response. And 200 is the most common status code in 2xx

Solution: 1. Check the Content-Type in the request header; 2. Check the data format in the request body; 3. Use the appropriate encoding format; 4. Use the appropriate request method; 5. Check the server-side support.

How to implement HTTP streaming in C++? Create an SSL stream socket using Boost.Asio and the asiohttps client library. Connect to the server and send an HTTP request. Receive HTTP response headers and print them. Receives the HTTP response body and prints it.

The HTTP request times out, and the server often returns the 504GatewayTimeout status code. This status code indicates that when the server executes a request, it still fails to obtain the resources required for the request or complete the processing of the request after a period of time. It is a status code of the 5xx series, which indicates that the server has encountered a temporary problem or overload, resulting in the inability to correctly handle the client's request. In the HTTP protocol, various status codes have specific meanings and uses, and the 504 status code is used to indicate request timeout issues. in customer

PHP CMS is a PHP-based open source content management system for managing website content. Its features include ease of use, powerful functionality, scalability, high security, and free open source. It can save time, improve website quality, enhance collaboration and reduce development costs, and is widely used in various websites such as news websites, blogs, corporate websites, e-commerce websites and community forums.

On the occasion of releasing the build 26040 version of Windows Server, Microsoft announced the official name of the product: Windows Server 2025. Also launched is the Windows11WindowsInsiderCanaryChannel version build26040. Some friends may still remember that many years ago someone successfully converted Windows NT from workstation mode to server mode, showing the commonalities between various versions of Microsoft operating systems. Although there are clear differences between Microsoft's current version of the server operating system and Windows 11, those who pay attention to the details may be curious: why Windows Server updated the brand,
