Home > Article > Backend Development > Detailed explanation of how to build a wap website with PHPCMS
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['HTTP_VIA'])) return true; if (isset($_SERVER['HTTP_X_NOKIA_CONNECTION_MODE'])) return true; if (isset($_SERVER['HTTP_X_UP_CALLING_LINE_ID'])) return true; if (strpos(strtoupper($_SERVER['HTTP_ACCEPT']), "VND.WAP.WML") > 0) { // Check whether the browser/gateway says it accepts WML. $br = "WML"; } else { $browser = isset($_SERVER['HTTP_USER_AGENT']) ? trim($_SERVER['HTTP_USER_AGENT']) : ''; if (empty($browser)) return true; $clientkeywords = array( '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' ); if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", $browser) && strpos($browser, 'ipad') === false) { $br = "WML"; } else { $br = "HTML"; } } if ($br == "WML") { return TRUE; } else { return FALSE; } } ?>
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('mobile', $template); } else { include template('content', $template); } }
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['id']}">
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 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!