PHPCMS Build WAP Mobile website

Source: Internet
Author: User
Phpcms Build PC-side web 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

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 * * @copyright (C) 2005-2010 phpcms * @license * @lastmodi FY 2010-10-27*///determine if mobile AccessfunctionCheck_wap () {if(isset($_server[' Http_via ']))returntrue; if(isset($_server[' Http_x_nokia_connection_mode ']))returntrue; if(isset($_server[' http_x_up_calling_line_id ']))returntrue; 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))returntrue; $clientkeywords=Array(            ' Nokia ', ' Sony ', ' Ericsson ', ' mot ', ' Samsung ', ' HTC ', ' SGH ', ' lg ', ' sharp ', ' sie-', ' Philips ', ' Panasonic ', ' Alcat  El ', ' 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") {        returnTRUE; } Else {        returnFALSE; }}?>
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);             Else {include$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

After all, the cell phone side of the column is not many


The above describes the Phpcms set up WAP mobile website, including the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.