The following will 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 用户自定义函数库 * * @copyright (C) 2005-2010 PHPCMS * @license * @lastmodify 2010-10-27 */ //判断是否手机访问 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 create a folder in the phpcms/templates/default template folder to store the templates of the mobile site
I created a folder called mobile
Then modify
phpcms/templates/modules/content/index.php file
Troublesome, make the judgment 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); }
In 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 mobile phones,
You can do this 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 version.
This is all about using PHPCMS to build a wap mobile website. If you need to know more about phpcms, please continue to pay attention to this site, and welcome all friends