search
HomeCMS TutorialPHPCMSHow to build a mobile site with phpcms

How to build a mobile site with phpcms

Oct 30, 2019 pm 05:38 PM
phpcms

How to build a mobile site with phpcms

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[&#39;HTTP_VIA&#39;])) return true;
    if (isset($_SERVER[&#39;HTTP_X_NOKIA_CONNECTION_MODE&#39;])) return true;
    if (isset($_SERVER[&#39;HTTP_X_UP_CALLING_LINE_ID&#39;])) return true;
    if (strpos(strtoupper($_SERVER[&#39;HTTP_ACCEPT&#39;]), "VND.WAP.WML") > 0) {
        // Check whether the browser/gateway says it accepts WML.
        $br = "WML";
    } else {
        $browser = isset($_SERVER[&#39;HTTP_USER_AGENT&#39;]) ? trim($_SERVER[&#39;HTTP_USER_AGENT&#39;]) : &#39;&#39;;
        if (empty($browser)) return true;
        $clientkeywords = array(
            &#39;nokia&#39;, &#39;sony&#39;, &#39;ericsson&#39;, &#39;mot&#39;, &#39;samsung&#39;, &#39;htc&#39;, &#39;sgh&#39;, &#39;lg&#39;, &#39;sharp&#39;, &#39;sie-&#39;
        , &#39;philips&#39;, &#39;panasonic&#39;, &#39;alcatel&#39;, &#39;lenovo&#39;, &#39;iphone&#39;, &#39;ipod&#39;, &#39;blackberry&#39;, &#39;meizu&#39;,
            &#39;android&#39;, &#39;netfront&#39;, &#39;symbian&#39;, &#39;ucweb&#39;, &#39;windowsce&#39;, &#39;palm&#39;, &#39;operamini&#39;,
            &#39;operamobi&#39;, &#39;opera mobi&#39;, &#39;openwave&#39;, &#39;nexusone&#39;, &#39;cldc&#39;, &#39;midp&#39;, &#39;wap&#39;, &#39;mobile&#39;
        );
        if (preg_match("/(" . implode(&#39;|&#39;, $clientkeywords) . ")/i", $browser) && strpos($browser, &#39;ipad&#39;) === 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(&#39;mobile&#39;, $template);
} else {
    include template(&#39;content&#39;, $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[&#39;id&#39;]}">

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!