phpcms v9框架自带的手机站制作较为复杂,需要单独去创建手机站的栏目,很不友好。

下面我将给大家分享不用单独添加手机站栏目,直接和pc栏目合并。

1、打开\phpcms\libs\functions\global.func.php文件,找到 template 模板方法,并替换成下面的代码

function template($module = 'content', $template = 'index', $style = '') {if(strpos($module, 'plugin/')!== false) {$plugin = str_replace('plugin/', '', $module);return p_template($plugin, $template,$style);}$module = str_replace('/', DIRECTORY_SEPARATOR, $module);if(defined('SITEID')) {$siteid = SITEID;} else {$siteid = param::get_cookie('siteid');}if (!$siteid) $siteid = 1;if(!empty($style) && preg_match('/([a-z0-9\-_]+)/is',$style)) {} elseif (empty($style) && !defined('STYLE')) {$sitelist = getcache('sitelist','commons');if(!empty($siteid)) {$style = $sitelist[$siteid]['default_style'];}} elseif (empty($style) && defined('STYLE')) {$style = STYLE;} else {$style = 'default';} if(!$style) $style = 'default';if(in_array($_GET['h'],array('wap','default','endefault'))){$style = $_GET['h'];param::set_cookie('HOST_ROUTE',$style); }if(!param::get_cookie('HOST_ROUTE')){ $style =$host_route = mobile_device_detect('wap',$style); param::set_cookie('HOST_ROUTE',$host_route); }else{$style = param::get_cookie('HOST_ROUTE');}if($siteid==2 && $style=='wap'){$style='enwap';   }elseif($siteid==1 && $style=='enwap'){$style='wap';   } if($siteid==2 && $style=='default'){$style='endefault';  }elseif($siteid==1 && $style=='endefault'){$style='default';   } $template_cache = pc_base::load_sys_class('template_cache');$compiledtplfile = PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR.'caches_template'.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.php';if(file_exists(PC_PATH.'templates'.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.html')) {if(!file_exists($compiledtplfile) || (@filemtime(PC_PATH.'templates'.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.html') > @filemtime($compiledtplfile))) {$template_cache->template_compile($module, $template, $style);}} else {$compiledtplfile = PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR.'caches_template'.DIRECTORY_SEPARATOR.'default'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.php';if(!file_exists($compiledtplfile) || (file_exists(PC_PATH.'templates'.DIRECTORY_SEPARATOR.'default'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.html') && filemtime(PC_PATH.'templates'.DIRECTORY_SEPARATOR.'default'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.html') > filemtime($compiledtplfile))) {$template_cache->template_compile($module, $template, 'default');} elseif (!file_exists(PC_PATH.'templates'.DIRECTORY_SEPARATOR.'default'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.html')) {showmessage('Template does not exist.'.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.html');}}return $compiledtplfile;
}function mobile_device_detect($mobileredirect=false,$desktopredirect=false,$iphone=true,$android=true,$opera=true){$mobile_browser   = false; // set mobile browser as false till we can prove otherwise$user_agent       = $_SERVER['HTTP_USER_AGENT']; // get the user agent value - this should be cleaned to ensure no nefarious input gets executed$accept           = $_SERVER['HTTP_ACCEPT']; // get the content accept value - this should be cleaned to ensure no nefarious input gets executedswitch(true){ // using a switch against the following statements which could return true is more efficient than the previous method of using if statementscase (preg_match('/^ipod/',$user_agent)||preg_match('/^iphone/',$user_agent)); // we find the words iphone or ipod in the user agent$mobile_browser = $iphone; // mobile browser is either true or false depending on the setting of iphone when calling the functionif(substr($iphone,0,4)=='http'){ // does the value of iphone resemble a url$mobileredirect = $iphone; // set the mobile redirect url to the url value stored in the iphone value} // ends the if for iphone being a urlbreak; // break out and skip the rest if we've had a match on the iphone or ipodcase (preg_match('/^android/',$user_agent));  // we find android in the user agent$mobile_browser = $android; // mobile browser is either true or false depending on the setting of android when calling the functionif(substr($android,0,4)=='http'){ // does the value of android resemble a url$mobileredirect = $android; // set the mobile redirect url to the url value stored in the android value} // ends the if for android being a urlbreak; // break out and skip the rest if we've had a match on androidcase (preg_match('/^opera mini/',$user_agent)); // we find opera mini in the user agent$mobile_browser = $opera; // mobile browser is either true or false depending on the setting of opera when calling the functionif(substr($opera,0,4)=='http'){ // does the value of opera resemble a rul$mobileredirect = $opera; // set the mobile redirect url to the url value stored in the opera value} // ends the if for opera being a url break; // break out and skip the rest if we've had a match on operacase (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|mobile|pda|psp|treo)/i',$user_agent)); // check if any of the values listed create a match on the user agent - these are some of the most common terms used in agents to identify them as being mobile devices - the i at the end makes it case insensitive$mobile_browser = true; // set mobile browser to truebreak; // break out and skip the rest if we've preg_match on the user agent returned true case ((strpos($accept,'text/vnd.wap.wml')>0)||(strpos($accept,'application/vnd.wap.xhtml+xml')>0)); // is the device showing signs of support for text/vnd.wap.wml or application/vnd.wap.xhtml+xml$mobile_browser = true; // set mobile browser to truebreak; // break out and skip the rest if we've had a match on the content accept headerscase (isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE'])); // is the device giving us a HTTP_X_WAP_PROFILE or HTTP_PROFILE header - only mobile devices would do this$mobile_browser = true; // set mobile browser to truebreak; // break out and skip the final step if we've had a return true on the mobile specfic headerscase (in_array(strtolower(substr($user_agent,0,4)),array('1207'=>'1207','3gso'=>'3gso','4thp'=>'4thp','501i'=>'501i','502i'=>'502i','503i'=>'503i','504i'=>'504i','505i'=>'505i','506i'=>'506i','6310'=>'6310','6590'=>'6590','770s'=>'770s','802s'=>'802s','a wa'=>'a wa','acer'=>'acer','acs-'=>'acs-','airn'=>'airn','alav'=>'alav','asus'=>'asus','attw'=>'attw','au-m'=>'au-m','aur '=>'aur ','aus '=>'aus ','abac'=>'abac','acoo'=>'acoo','aiko'=>'aiko','alco'=>'alco','alca'=>'alca','amoi'=>'amoi','anex'=>'anex','anny'=>'anny','anyw'=>'anyw','aptu'=>'aptu','arch'=>'arch','argo'=>'argo','bell'=>'bell','bird'=>'bird','bw-n'=>'bw-n','bw-u'=>'bw-u','beck'=>'beck','benq'=>'benq','bilb'=>'bilb','blac'=>'blac','c55/'=>'c55/','cdm-'=>'cdm-','chtm'=>'chtm','capi'=>'capi','comp'=>'comp','cond'=>'cond','craw'=>'craw','dall'=>'dall','dbte'=>'dbte','dc-s'=>'dc-s','dica'=>'dica','ds-d'=>'ds-d','ds12'=>'ds12','dait'=>'dait','devi'=>'devi','dmob'=>'dmob','doco'=>'doco','dopo'=>'dopo','el49'=>'el49','erk0'=>'erk0','esl8'=>'esl8','ez40'=>'ez40','ez60'=>'ez60','ez70'=>'ez70','ezos'=>'ezos','ezze'=>'ezze','elai'=>'elai','emul'=>'emul','eric'=>'eric','ezwa'=>'ezwa','fake'=>'fake','fly-'=>'fly-','fly_'=>'fly_','g-mo'=>'g-mo','g1 u'=>'g1 u','g560'=>'g560','gf-5'=>'gf-5','grun'=>'grun','gene'=>'gene','go.w'=>'go.w','good'=>'good','grad'=>'grad','hcit'=>'hcit','hd-m'=>'hd-m','hd-p'=>'hd-p','hd-t'=>'hd-t','hei-'=>'hei-','hp i'=>'hp i','hpip'=>'hpip','hs-c'=>'hs-c','htc '=>'htc ','htc-'=>'htc-','htca'=>'htca','htcg'=>'htcg','htcp'=>'htcp','htcs'=>'htcs','htct'=>'htct','htc_'=>'htc_','haie'=>'haie','hita'=>'hita','huaw'=>'huaw','hutc'=>'hutc','i-20'=>'i-20','i-go'=>'i-go','i-ma'=>'i-ma','i230'=>'i230','iac'=>'iac','iac-'=>'iac-','iac/'=>'iac/','ig01'=>'ig01','im1k'=>'im1k','inno'=>'inno','iris'=>'iris','jata'=>'jata','java'=>'java','kddi'=>'kddi','kgt'=>'kgt','kgt/'=>'kgt/','kpt '=>'kpt ','kwc-'=>'kwc-','klon'=>'klon','lexi'=>'lexi','lg g'=>'lg g','lg-a'=>'lg-a','lg-b'=>'lg-b','lg-c'=>'lg-c','lg-d'=>'lg-d','lg-f'=>'lg-f','lg-g'=>'lg-g','lg-k'=>'lg-k','lg-l'=>'lg-l','lg-m'=>'lg-m','lg-o'=>'lg-o','lg-p'=>'lg-p','lg-s'=>'lg-s','lg-t'=>'lg-t','lg-u'=>'lg-u','lg-w'=>'lg-w','lg/k'=>'lg/k','lg/l'=>'lg/l','lg/u'=>'lg/u','lg50'=>'lg50','lg54'=>'lg54','lge-'=>'lge-','lge/'=>'lge/','lynx'=>'lynx','leno'=>'leno','m1-w'=>'m1-w','m3ga'=>'m3ga','m50/'=>'m50/','maui'=>'maui','mc01'=>'mc01','mc21'=>'mc21','mcca'=>'mcca','medi'=>'medi','meri'=>'meri','mio8'=>'mio8','mioa'=>'mioa','mo01'=>'mo01','mo02'=>'mo02','mode'=>'mode','modo'=>'modo','mot '=>'mot ','mot-'=>'mot-','mt50'=>'mt50','mtp1'=>'mtp1','mtv '=>'mtv ','mate'=>'mate','maxo'=>'maxo','merc'=>'merc','mits'=>'mits','mobi'=>'mobi','motv'=>'motv','mozz'=>'mozz','n100'=>'n100','n101'=>'n101','n102'=>'n102','n202'=>'n202','n203'=>'n203','n300'=>'n300','n302'=>'n302','n500'=>'n500','n502'=>'n502','n505'=>'n505','n700'=>'n700','n701'=>'n701','n710'=>'n710','nec-'=>'nec-','nem-'=>'nem-','newg'=>'newg','neon'=>'neon','netf'=>'netf','noki'=>'noki','nzph'=>'nzph','o2 x'=>'o2 x','o2-x'=>'o2-x','opwv'=>'opwv','owg1'=>'owg1','opti'=>'opti','oran'=>'oran','p800'=>'p800','pand'=>'pand','pg-1'=>'pg-1','pg-2'=>'pg-2','pg-3'=>'pg-3','pg-6'=>'pg-6','pg-8'=>'pg-8','pg-c'=>'pg-c','pg13'=>'pg13','phil'=>'phil','pn-2'=>'pn-2','ppc;'=>'ppc;','pt-g'=>'pt-g','palm'=>'palm','pana'=>'pana','pire'=>'pire','pock'=>'pock','pose'=>'pose','psio'=>'psio','qa-a'=>'qa-a','qc-2'=>'qc-2','qc-3'=>'qc-3','qc-5'=>'qc-5','qc-7'=>'qc-7','qc07'=>'qc07','qc12'=>'qc12','qc21'=>'qc21','qc32'=>'qc32','qc60'=>'qc60','qci-'=>'qci-','qwap'=>'qwap','qtek'=>'qtek','r380'=>'r380','r600'=>'r600','raks'=>'raks','rim9'=>'rim9','rove'=>'rove','s55/'=>'s55/','sage'=>'sage','sams'=>'sams','sc01'=>'sc01','sch-'=>'sch-','scp-'=>'scp-','sdk/'=>'sdk/','se47'=>'se47','sec-'=>'sec-','sec0'=>'sec0','sec1'=>'sec1','semc'=>'semc','sgh-'=>'sgh-','shar'=>'shar','sie-'=>'sie-','sk-0'=>'sk-0','sl45'=>'sl45','slid'=>'slid','smb3'=>'smb3','smt5'=>'smt5','sp01'=>'sp01','sph-'=>'sph-','spv '=>'spv ','spv-'=>'spv-','sy01'=>'sy01','samm'=>'samm','sany'=>'sany','sava'=>'sava','scoo'=>'scoo','send'=>'send','siem'=>'siem','smar'=>'smar','smit'=>'smit','soft'=>'soft','sony'=>'sony','t-mo'=>'t-mo','t218'=>'t218','t250'=>'t250','t600'=>'t600','t610'=>'t610','t618'=>'t618','tcl-'=>'tcl-','tdg-'=>'tdg-','telm'=>'telm','tim-'=>'tim-','ts70'=>'ts70','tsm-'=>'tsm-','tsm3'=>'tsm3','tsm5'=>'tsm5','tx-9'=>'tx-9','tagt'=>'tagt','talk'=>'talk','teli'=>'teli','topl'=>'topl','tosh'=>'tosh','up.b'=>'up.b','upg1'=>'upg1','utst'=>'utst','v400'=>'v400','v750'=>'v750','veri'=>'veri','vk-v'=>'vk-v','vk40'=>'vk40','vk50'=>'vk50','vk52'=>'vk52','vk53'=>'vk53','vm40'=>'vm40','vx98'=>'vx98','virg'=>'virg','vite'=>'vite','voda'=>'voda','vulc'=>'vulc','w3c '=>'w3c ','w3c-'=>'w3c-','wapj'=>'wapj','wapp'=>'wapp','wapu'=>'wapu','wapm'=>'wapm','wig '=>'wig ','wapi'=>'wapi','wapr'=>'wapr','wapv'=>'wapv','wapy'=>'wapy','wapa'=>'wapa','waps'=>'waps','wapt'=>'wapt','winc'=>'winc','winw'=>'winw','wonu'=>'wonu','x700'=>'x700','xda2'=>'xda2','xdag'=>'xdag','yas-'=>'yas-','your'=>'your','zte-'=>'zte-','zeto'=>'zeto','acs-'=>'acs-','alav'=>'alav','alca'=>'alca','amoi'=>'amoi','aste'=>'aste','audi'=>'audi','avan'=>'avan','benq'=>'benq','bird'=>'bird','blac'=>'blac','blaz'=>'blaz','brew'=>'brew','brvw'=>'brvw','bumb'=>'bumb','ccwa'=>'ccwa','cell'=>'cell','cldc'=>'cldc','cmd-'=>'cmd-','dang'=>'dang','doco'=>'doco','eml2'=>'eml2','eric'=>'eric','fetc'=>'fetc','hipt'=>'hipt','http'=>'http','ibro'=>'ibro','idea'=>'idea','ikom'=>'ikom','inno'=>'inno','ipaq'=>'ipaq','jbro'=>'jbro','jemu'=>'jemu','java'=>'java','jigs'=>'jigs','kddi'=>'kddi','keji'=>'keji','kyoc'=>'kyoc','kyok'=>'kyok','leno'=>'leno','lg-c'=>'lg-c','lg-d'=>'lg-d','lg-g'=>'lg-g','lge-'=>'lge-','libw'=>'libw','m-cr'=>'m-cr','maui'=>'maui','maxo'=>'maxo','midp'=>'midp','mits'=>'mits','mmef'=>'mmef','mobi'=>'mobi','mot-'=>'mot-','moto'=>'moto','mwbp'=>'mwbp','mywa'=>'mywa','nec-'=>'nec-','newt'=>'newt','nok6'=>'nok6','noki'=>'noki','o2im'=>'o2im','opwv'=>'opwv','palm'=>'palm','pana'=>'pana','pant'=>'pant','pdxg'=>'pdxg','phil'=>'phil','play'=>'play','pluc'=>'pluc','port'=>'port','prox'=>'prox','qtek'=>'qtek','qwap'=>'qwap','rozo'=>'rozo','sage'=>'sage','sama'=>'sama','sams'=>'sams','sany'=>'sany','sch-'=>'sch-','sec-'=>'sec-','send'=>'send','seri'=>'seri','sgh-'=>'sgh-','shar'=>'shar','sie-'=>'sie-','siem'=>'siem','smal'=>'smal','smar'=>'smar','sony'=>'sony','sph-'=>'sph-','symb'=>'symb','t-mo'=>'t-mo','teli'=>'teli','tim-'=>'tim-','tosh'=>'tosh','treo'=>'treo','tsm-'=>'tsm-','upg1'=>'upg1','upsi'=>'upsi','vk-v'=>'vk-v','voda'=>'voda','vx52'=>'vx52','vx53'=>'vx53','vx60'=>'vx60','vx61'=>'vx61','vx70'=>'vx70','vx80'=>'vx80','vx81'=>'vx81','vx83'=>'vx83','vx85'=>'vx85','wap-'=>'wap-','wapa'=>'wapa','wapi'=>'wapi','wapp'=>'wapp','wapr'=>'wapr','webc'=>'webc','whit'=>'whit','winw'=>'winw','wmlb'=>'wmlb','xda-'=>'xda-',))); // check against a list of trimmed user agents to see if we find a match$mobile_browser = true; // set mobile browser to truebreak; // break even though it's the last statement in the switch so there's nothing to break away from but it seems better to include it than exclude it} // ends the switch // tell adaptation services (transcoders and proxies) to not alter the content based on user agent as it's already being managed by this scriptheader('Cache-Control: no-transform'); // http://mobiforge.com/developing/story/setting-http-headers-advise-transcoding-proxiesheader('Vary: User-Agent, Accept'); // http://mobiforge.com/developing/story/setting-http-headers-advise-transcoding-proxies// if redirect (either the value of the mobile or desktop redirect depending on the value of $mobile_browser) is true redirect else we return the status of $mobile_browser$redirect = ($mobile_browser==true) ? $mobileredirect : $desktopredirect;return $redirect;
}

2、打开\phpcms\templates 目录,把default 默认pc模板复制一份,并改名为wap目录

wap里代码和pc模板代码写法一样,pc怎么写 wap就怎么写

3、pc访问路径:/index.php?h=defalut

wap访问路径:/index.php?h=wap


大功告成,喜欢的话给个关注吧!

phpcms v9摆脱手机门户,轻松搭建wap手机站相关推荐

  1. 用PHPcms V9四步完成WAP手机站搭建

    用PHPCMS最新发布的V9搭建了ONOW中文网,WEB网站(www.onow.cn)完成后,有用户提供手机访问的问题, 于是着手搭建ONOW手机WAP站(3g.onow.cn).用PHPCMS V9 ...

  2. 【phpcms-v9】phpcms-v9系统搭建wap网站

    注意:phpcms-v9中的WAP站点对应的是手机门户模块 应用PHPCMS V9轻松完成WAP手机网站搭建全教程 用PHPCMS最新发布的V9搭建了PHPCMS研究中心网站(phpcms.org.c ...

  3. 【phpcms-v9】phpcms-v9中建立wap手机站点

    web网站用的是phpcms v9搭建的,为了方便手机用户浏览网站,于是用phpcms v9自带的手机门户模块搭建了个wap站(http://s.8368.org); 通过简单的几步设置.很快搭建好了 ...

  4. php v9数据库,phpcms V9数据库表名称表

    v9_admin 管理员表www.9lyp.com v9_admin_panel 快捷面板www.9lyp.com v9_admin_role 角色表3f43dc8 v9_admin_role_pri ...

  5. 手机网站php模板修改,Phpcms V9自定义手机WAP模板新方法

    近来越来越多手机WAP.自适应网站,可见移动网页是未来,响应式是未来!但是在实际经验中,CMSYOU发现:响应式自适应虽然在国外非常流行了.大家都在追随,不过在国内,由于XP上ie6.IE8,带宽等问 ...

  6. Phpcms V9手机门户设置教程:怎么用PC V9做手机网站

    一.在PHPcms V9管理后台设置手机门户 1.1.开启手机网站.位置:模块 >手机门户 > 添加手机站点,具体设置可参照截图: 填写站点名和LOGO文件相对位置,绑定用于手机网站的二级 ...

  7. phpcms v9手机站wap后台绑定任意单页面(简单二开)

    默认的phpcms v9手机门户后台管理,添加栏目的时候无法绑定单页面,虽然有人可以直接通过传递单页面id的方式调用,但是毕竟不是很方便,简单二开,让你实现后台栏目绑定任意的单页面 一.前端代码: ( ...

  8. phpcms V9手机门户模块实现单页功能的方法

    第一步:实现分类管理可以绑定单页的修改办法 需要修改的文件所在目录:\phpcms\modules\wap\templates ,目录下文件type_manage.tpl.php为手机门户分类管理的模 ...

  9. phpcms v9手机门户配置方法

    1.确定一个域名作为你手机wap站点的访问域名,例如:http://m.tezhengzong.com .接下来在域名管理系统中简析这个域名到你的服务器地址. 2.修改\caches\configs\ ...

  10. phpcms v9手机门户配置方法_无需整理

    为什么80%的码农都做不了架构师?>>>    1.确定一个域名作为你手机wap站点的访问域名,例如:http://m.tezhengzong.com .接下来在域名管理系统中简析这 ...

最新文章

  1. Spring Boot 最最最常用的注解梳理
  2. python3.7源码分析-字典
  3. C++ multimap的用法
  4. PaddleHub 口罩检测
  5. 用verilog实现检测1的个数_入门指南:用Python实现实时目标检测(内附代码)
  6. 安装 Python IDLE
  7. python画小猪乔治_小孩挑食难搞定?试下猪肉这样炒,简单5步超下饭,比牛肉还香嫩...
  8. drill apache_如何使用Apache Drill分析高度动态的数据集
  9. 【转】Mac系统中安装homebrew(类似redhat|Centos中的yum;类似Ubuntu中的apt-get)
  10. esx4克隆后的处理工作
  11. 导 Kinect2库,opencv库,pcl库
  12. Iaas,paas,saas区别与联系
  13. 用Aria2加速下载数据集等
  14. linux+usb串口驱动安装ch341ser,U7编程器USB转串口驱动程序CH341SER
  15. 如何批量隔行删除Excel行
  16. 计算机组装维修设置还原点,怎样恢复出厂设置组装电脑
  17. html 播放amr ios,关于iOS设备以amr格式播放音频文件
  18. iOS获取路由器地址
  19. Java-Swing内嵌网页判断网址类型
  20. “融晶保肾调代谢”公益健康大讲堂(第二期)在贵阳强直医院开展

热门文章

  1. Axure RP9 制作下拉式菜单
  2. 003_SSS_ Tackling the Generative Learning Trilemma with Denoising Diffusion GANs
  3. PyTorch搭建LSTM实现多变量输入多变量输出时间序列预测(多任务学习)
  4. 张健和他的Fcoin
  5. html语言单词背不下来,英语单词怎么都背不下来怎么办
  6. office2013 vol版本
  7. 手机上的APP都是用什么编程语言写的?
  8. 计算机一黑屏就显示当前账户已锁定,电脑黑屏用户已锁定账户怎么办?
  9. ALU计算机专业术语,计算机专业术语大全
  10. 【FFmpeg】在FFmpeg里添加自研编码器方法