readme.txt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. 配置项目配置文件:
  2. 'LAYOUT_ON'=>true
  3. 在项目Conf目录下添加文件 tags.php
  4. <?php
  5. return array(
  6. 'action_begin'=>array('SwitchMobileTpl')
  7. )
  8. 将Tpl文件夹复制到项目中,作为项目的模板。
  9. 将SwitchMobileTplBehavior.class.php 复制到 项目目录下 Lib/Behavior 目录下。
  10. 将TemplateMobile.class.php 文件复制到 ThinkPHP/Extend/Driver/Template 下。
  11. 支持手机客户端跳转,需要修改核心文件 ThinkPHP/Common/functions.php 中得redirect函数,
  12. 修改如下:
  13. function redirect($url, $time=0, $msg='') {
  14. //多行URL地址支持
  15. $url = str_replace(array("\n", "\r"), '', $url);
  16. if (empty($msg))
  17. $msg = "系统将在{$time}秒之后自动跳转到{$url}!";
  18. if (!headers_sent()) {
  19. // redirect
  20. if (0 === $time) {
  21. //手机客户端跳转发送redirect的header
  22. if(defined('IS_CLIENT') && IS_CLIENT){
  23. if(''!==__APP__){
  24. $url=substr($url,strlen(__APP__));
  25. }
  26. header('redirect:'.$url);
  27. }else{
  28. header('Location: ' . $url);
  29. }
  30. } else {
  31. header("refresh:{$time};url={$url}");
  32. echo($msg);
  33. }
  34. exit();
  35. } else {
  36. $str = "<meta http-equiv='Refresh' content='{$time};URL={$url}'>";
  37. if ($time != 0)
  38. $str .= $msg;
  39. exit($str);
  40. }
  41. }