Home php教程 php手册 使用PHPCMS搭建wap手机网站

使用PHPCMS搭建wap手机网站

Jun 06, 2016 pm 07:44 PM

PHPCMS搭建PC端网站比较方便,但是在wap手机端方面却不怎么实用,而且自带的手机建站感觉不是很好,而且模版不好控制,现在对其进行修改,手机建站个人感觉比较

下面给大家讲使用PHPCMS搭建wap手机网站的方法,具体内容请看下文。

首先在phpcms/libs/functions/extention.func.php里面写入判断手机访问的自定义函数

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; } } ?>

然后在phpcms/templates/default模版文件夹里建立一个文件夹存放手机站的模版

我建立一个叫mobile的文件夹

然后修改
phpcms/templates/modules/content/index.php文件

麻烦点,分别在频道页,列表页,,内容页加载模版时进行判断
比如:

     if (check_wap()) { include template('mobile', $template); } else { include template('content', $template); }

这样当用手机访问时会加载mobile文件夹里面的模版,mobile文件夹里面的模版名字要跟PC端的一样。
当然,在生成静态页面时会出现问题,目前解决的办法是手机端用动态,
调用数据时可以这样


毕竟手机端的栏目不是很多。

关于使用PHPCMS搭建wap手机网站的全部内容就介绍完了,需要了解有关phpcms知识的,请持续关注本站,同时欢迎各位朋友

Statement of this Website
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

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)