PHPCMS is more convenient to build a PC website, 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 it is To modify it,
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; } } ?>
and then in the phpcms/templates/default template folder Create a folder to store the template of the mobile site
Create a folder called mobile
Then modify the
phpcms/templates/modules/content/index.php file
Troublesome point, make a 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, mobile will be loaded when accessed by mobile phone The templates in the folder and the template names in the mobile folder must be the same as those 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.
You can do this when calling data
?1<a href="index.php?m=content&c=index&a=show&catid=25&id={$r['id']}">
The above is the detailed content of How to build a mobile site with phpcms. For more information, please follow other related articles on the PHP Chinese website!