dedecmsv5.7sp2utf-8;(已經(jīng)為大家做好修改好的腳本,下載覆蓋就可以)。
后臺(tái)添加一鍵更新手機(jī)端、更新手機(jī)端主頁(yè)、更新手機(jī)端文檔的功能;
手機(jī)端打開頁(yè)面時(shí)自動(dòng)跳轉(zhuǎn)到手機(jī)二級(jí)域名網(wǎng)站對(duì)應(yīng)的頁(yè)面;
實(shí)現(xiàn)手機(jī)端PC端數(shù)據(jù)同步適配;
手機(jī)端生成靜態(tài)頁(yè)面;
1、對(duì)/dede/目錄的修改
/dede/inc/目錄下修改如下文件
inc_archives_functions.php
inc_menu.php
/dede/目錄下修改如下文件
makehtml_all.php
makehtml_list_action.php
makehtml_archives_action.php
makehtml_homepage.php
config.php
/dede/目錄下增加如下文件
makehtml_all_m.php
makehtml_list_action_m.php
makehtml_archives_action_m.php
makehtml_homepage_m.php
zchange_sysconfig.php
zchange_sysconfig_m.php
/dede/templets/目錄下修改如下文件
makehtml_homepage.htm
/dede/templets/目錄下增加如下文件
makehtml_homepage_m.htm
makehtml_all_m.htm
makehtml_list_m.htm
makehtml_archives_m.htm
2、對(duì)/include/目錄的修改
/include/目錄下修改如下文件
Arc.archives.class.php
/include/目錄下增加如下文件
arc.archives_m.class.php
arc.listview_m.class.php
common.inc.php
1、下載程序目錄,依次根據(jù)實(shí)現(xiàn)情況對(duì)文件進(jìn)行覆蓋。
2、打開dedecms織夢(mèng)管理系統(tǒng)后臺(tái),點(diǎn)擊系統(tǒng)菜單-系統(tǒng)設(shè)置-系統(tǒng)基本參數(shù)設(shè)置-添加新變量;添加以下兩個(gè)變量。
變量名稱:cfg_mbasehost;變量值:http://m.dede.com(需要根據(jù)實(shí)際的域名進(jìn)行修改,例如域名為abc.com則變量值應(yīng)該為http://m.abc.com) ;參數(shù)說明:手機(jī)站根網(wǎng)址:
變量名稱:cfg_pbasehost;變量值:http://www.dede.com(需要根據(jù)實(shí)際的域名進(jìn)行修改,例如域名為abc.com則變量值應(yīng)該為http://www.abc.com) ;參數(shù)說明:PC端根網(wǎng)址:
兩個(gè)變量所屬的組都為“站點(diǎn)設(shè)置”。
3、將文章命名規(guī)則改成{typedir}/{aid}.html,這樣的目錄URL短而且有利于seo優(yōu)化。
4、如果發(fā)布文章所用的文件名稱為自定義的文件名而且是字母則可以跳過此步,如果習(xí)慣發(fā)布文章用數(shù)字當(dāng)作文件名的話,需要將article_article.htm中的{dede:field name="filename" /}改成{dede:field name="id" /},主用用于跳轉(zhuǎn)時(shí)使用數(shù)據(jù)同步。
5、處理圖片問題,由于圖片存儲(chǔ)在/uploads/下,因此需要將m.域名.com下的圖片重定向到www.域名.com下的/uploads/下。以下是代碼,修改時(shí)只需將域名進(jìn)行替換就可以,這里的環(huán)境為apache。
<VirtualHost *:80>
ServerAdmin admin@myhost.com
ServerName m.dede.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^m.dede.com$ [NC]
RewriteRule ^/uploads/(.*) http://www.dede.com/uploads/$1 [NC,L]
DocumentRoot "D:/DedeAMPZ/WebRoot/dede/m"
php_admin_value open_basedir "D:/DedeAMPZ/WebRoot/dede"
</VirtualHost>
##VhostEnd
<VirtualHost *:80>
ServerAdmin admin@myhost.com
ServerName www.dede.com
ServerAlias dede.com
DocumentRoot "D:/DedeAMPZ/WebRoot/dede"
php_admin_value open_basedir "D:/DedeAMPZ/WebRoot/dede"
</VirtualHost>
##VhostEnd
6、使用時(shí),發(fā)布文章需要在PC端模式下,只需要進(jìn)行更新下PC端主頁(yè)就可以切換到PC端模式下。
7、下載下來的為utf-8編碼的dede手機(jī)端靜態(tài)化插件,如果系統(tǒng)是GBK,可以使用記事本另存為ANSI編碼格式。
8、關(guān)于PC頁(yè)面跳轉(zhuǎn)到相應(yīng)手機(jī)頁(yè)面的代碼:
index.htm首頁(yè)跳轉(zhuǎn)
<meta http-equiv="mobile-agent" content="format=xhtml;url={dede:global.cfg_mobileurl/}">
<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_mobileurl/}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>
list_article.htm:列表頁(yè)跳轉(zhuǎn)
<meta http-equiv="mobile-agent" content="format=xhtml;url={dede:type}[field:typelink function='str_replace("www","m","@me")' /]{/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:type}[field:typelink function='str_replace("www","m","@me")' /]{/dede:type}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>
article_article.htm:文章頁(yè)跳轉(zhuǎn)
<meta http-equiv="mobile-agent" content="format=xhtml;url={dede:type}[field:typelink function='str_replace("www","m","@me")' /]{/dede:type}{dede:field name="filename" /}.html" />
<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:type}[field:typelink function='str_replace("www","m","@me")' /]{/dede:type}{dede:field name="filename" /}.html";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>
9、有時(shí)打開手機(jī)版時(shí)跳轉(zhuǎn)到install/index.php頁(yè)面
修改/m/目錄下的index.php腳本文件
if(!file_exists('http://www.de.com/data/common.inc.php'))
{
header('Location:install/index.php');
exit();
}
clearstatcache();
if(!file_exists(dirname(__FILE__) . "/../data/common.inc.php"))
{
// header('Location:install/index.php');
echo 'it is not exists';
exit();
}
10、發(fā)生生成靜態(tài)化樣式錯(cuò)誤的問題:
解決方法是替換CSS樣式和JS,例如替換CSS和JS文件的引入:
<link rel="stylesheet" href="assets/css/amazeui.min.css" />修改為<link rel="stylesheet" href="/assets/css/amazeui.min.css" />JS文件也是如何在最開始前加上"/"即可。
11、其他問題
其他問題可能由于緩存引起,最好退出瀏覽器或清除緩存來解決。
聯(lián)系客服