Phpcms How to build WAP website? Phpcms to build a PC-side site is more convenient, but in the WAP mobile phone side is not practical, and the mobile phone built station feel is not very good, and the template is not good control, and now modify it, mobile phone station personal feeling more convenient. This article introduces the use of Phpcms to build WAP mobile website, the need for friends can refer to. We hope to help you.
The following is to tell you how to use Phpcms to build WAP mobile website, the specific content please see below.
First , write a custom function in phpcms/libs/functions/extention.func.php that determines the phone's access.
<?php/** * extention.func.php user-defined function library * *///determine if the phone accesses 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 template of the mobile station
I set up a folder called Mobile.
And then Modify
phpcms/templates/modules/content/index.php file
Trouble points, respectively, in the Channel page, list page, content page load template to judge
Like what:
if (Check_wap ()) { include template (' Mobile ', $template); } else { include template (' content ', $template); }}
This will load the template in the Mobile folder when accessed by mobile phone, the template name in the Mobile folder should be the same as the PC side.
Of course, there will be problems when generating static pages, the current solution is to use mobile phone-side dynamic,
You can do this when you call data
<a href= "index.php?m=content&c=index&a=show&catid=25&id={$r [' ID ']}" >
After all, the cell phone side of the column is not many.
Related recommendations:
How to implement comment reply delete function in PHP
PHP use Redis queue to implement e-commerce order automatic Confirmation receipt
detailed php7 how to implement MongoDB fuzzy query