织梦dedecms手机版伪静态教程(2)

改成

{dede:field.content runphp=yes} global $cfg_basehost; $str = @me; $search = '/(<img.*?)width=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is'; $search1 = '/(<img.*?)height=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is'; $search2 = '#(<img.*?style=".*?)width:\d+px;([^"]*?.*?>)#i'; $search3 = '#(<img.*?style=".*?)height:\d+px;([^"]*?.*?>)#i'; $content = preg_replace($search,'$1$3',$str); $content = preg_replace($search1,'$1$3',$content); $content = preg_replace($search2,'$1$2',$content); $content = preg_replace($search3,'$1$2',$content); @me = $content; @me = str_replace('/uploads/allimg/', $cfg_basehost.'/uploads/allimg/', $content); {/dede:field.content}  

搜索框代码改成静态的js提交搜索,参考下面代码,注意标红的地方

<script type="text/javascript"> function search() { var q = document.getElementById("q").value; window.location.href = ""+q+".html"; } function enterIn(obj,evt) { var evt = evt ? evt : (window.event ? window.event : null); if (evt.keyCode == 13) { var q = obj.value; window.location.href = ""+q+".html"; } } </script> <form action="" method="post" onsubmit="return false"> <div> <h4>搜索</h4> <input name="q" id="q" onkeydown="enterIn(this,event);" type="text" /> <button type="submit" onclick="search()">搜索</button> </div> </form>  

电脑版跳转到移动版代码

1)首页

<meta http-equiv="mobile-agent" content="format=xhtml;url={dede:global.cfg_mobile/}"> <script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?mobile")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="{dede:global.cfg_mobile/}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>  

2)列表

<meta http-equiv="mobile-agent" content="format=xhtml;url={dede:global.cfg_mobile/}{dede:type}[field:typeurl/]{/dede:type}"> <script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?mobile")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="{dede:global.cfg_mobile/}{dede:type}[field:typeurl/]{/dede:type}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>  

3)内容

<meta http-equiv="mobile-agent" content="format=xhtml;url={dede:global.cfg_mobile/}{dede:field.id runphp=yes}$result=GetOneArchive(@me);@me=$result['arcurl'];{/dede:field.id}"> <script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?mobile")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="{dede:global.cfg_mobile/}{dede:field.id runphp=yes}$result=GetOneArchive(@me);@me=$result['arcurl'];{/dede:field.id}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>  

织梦手机版目录版url伪静态,完成。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/d9aa7c43df51221aadaa8f1a50de699a.html