dedecmsv5.7sp2utf-8;(已經(jīng)為大家做好修改好的腳本,下載覆蓋就可以)。
后臺添加一鍵更新手機端、更新手機端主頁(yè)、更新手機端文檔的功能;
手機端打開(kāi)頁(yè)面時(shí)自動(dòng)跳轉到手機二級域名網(wǎng)站對應的頁(yè)面;
實(shí)現手機端PC端數據同步適配;
手機端生成靜態(tài)頁(yè)面;
1、對/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、對/include/目錄的修改
/include/目錄下修改如下文件
Arc.archives.class.php
/include/目錄下增加如下文件
arc.archives_m.class.php
arc.listview_m.class.php
common.inc.php
1、下載程序目錄,依次根據實(shí)現情況對文件進(jìn)行覆蓋。
2、打開(kāi)dedecms織夢(mèng)管理系統后臺,點(diǎn)擊系統菜單-系統設置-系統基本參數設置-添加新變量;添加以下兩個(gè)變量。
變量名稱(chēng):cfg_mbasehost;變量值:http://m.dede.com(需要根據實(shí)際的域名進(jìn)行修改,例如域名為abc.com則變量值應該為http://m.abc.com) ;參數說(shuō)明:手機站根網(wǎng)址:
變量名稱(chēng):cfg_pbasehost;變量值:http://www.dede.com(需要根據實(shí)際的域名進(jìn)行修改,例如域名為abc.com則變量值應該為http://www.abc.com) ;參數說(shuō)明:PC端根網(wǎng)址:
兩個(gè)變量所屬的組都為“站點(diǎn)設置”。

3、將文章命名規則改成{typedir}/{aid}.html,這樣的目錄URL短而且有利于seo優(yōu)化。
4、如果發(fā)布文章所用的文件名稱(chēng)為自定義的文件名而且是字母則可以跳過(guò)此步,如果習慣發(fā)布文章用數字當作文件名的話(huà),需要將article_article.htm中的{dede:field name="filename" /}改成{dede:field name="id" /},主用用于跳轉時(shí)使用數據同步。
5、處理圖片問(wèn)題,由于圖片存儲在/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、下載下來(lái)的為utf-8編碼的dede手機端靜態(tài)化插件,如果系統是GBK,可以使用記事本另存為ANSI編碼格式。
8、關(guān)于PC頁(yè)面跳轉到相應手機頁(yè)面的代碼:
index.htm首頁(yè)跳轉
<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è)跳轉
<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è)跳轉
<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í)打開(kāi)手機版時(shí)跳轉到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)化樣式錯誤的問(wèn)題:
解決方法是替換CSS樣式和JS,例如替換CSS和JS文件的引入:
<link rel="stylesheet" href="assets/css/amazeui.min.css" />修改為<link rel="stylesheet" href="/assets/css/amazeui.min.css" />JS文件也是如何在最開(kāi)始前加上"/"即可。
11、其他問(wèn)題
其他問(wèn)題可能由于緩存引起,最好退出瀏覽器或清除緩存來(lái)解決。
聯(lián)系客服