找回密码
 立即注册
搜索
查看: 1789|回复: 1

共用一个数据库实现pc网站和手机网站的制作

[复制链接]

581

主题

110

回帖

4066

积分

管理员

积分
4066

众神之神

发表于 2017-7-17 19:05:24 | 显示全部楼层 |阅读模式
原文地址:http://bbs.phpcms.cn/thread-881733-1-1.html

1.假设PC端为主站;

2.开发完PC端后将PC端全部代码copy一份;

3.在拷贝出来的目录\phpcms\phpcms\templates\default\content\下可以写移动端的模板界面;


在pc端的header.html文件中做判断当前是PC还是移动设备:

  1. <link rel="alternate" type="application/vnd.wap.xhtml+xml" media="handheld" href="http://m.test.com/"/>
  2. <script>
  3. (function(g) {
  4.         var KZ = g.KZ ? g.KZ : {},
  5.                         pattern = /android|bb\d+|ucweb|meego|avantgo|bada\/|blackberry|transcoder|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i;
  6.         KZ.redirect = function(url) {
  7.                 if (g.navigator.userAgent.match(pattern)) g.location = url
  8.         };
  9.         g.KZ = KZ
  10. })(window);
  11. </script>
  12. <script type="text/javascript">KZ.redirect("http://m.test.com/");</script>
复制代码

关于新增虚拟主机看这里

图片路附件用可以用绝对路径





581

主题

110

回帖

4066

积分

管理员

积分
4066

众神之神

 楼主| 发表于 2017-8-2 12:01:27 | 显示全部楼层
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|十三博客 ( 鲁ICP备2023000528号 )

GMT+8, 2026-6-1 16:16 , Processed in 0.074486 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表