Dokuwiki 自動切換 Mobile 呈現頁面方式

因為最近開始使用 hTC Incredible S , 有這樣的需求, 很快找了一些現成的資料, 立即實現這樣的功能.

  • 下載安裝 dokumobile Template
    cd /var/www/html/wiki/lib/tpl
    wget http://kjh.ca/dokumobile_2010_02_28.zip
    unzip dokumobile_2010_02_28.zip
  • 會出現 dokumobile 目錄, 然後修改 top_bar.php 第9-11行, 解決無法出現表頭圖樣的問題, 修改如下
         <td width="33%" style="border:0;" align="left"><img src="<?php echo DOKU_TPL?>images/icon_left.png" id="toggle_toc" /></td>
         <td width="33%" style="border:0;" align="center"><img src="<?php echo DOKU_TPL?>images/icon_middle.png" id="toggle_admin" /></td>
         <td width="33%" style="border:0;" align="right"><img src="<?php echo DOKU_TPL?>images/icon_right.png" id="toggle_nav" /></td>
  • 下載 Mobile_Detect.php 到 conf 目錄內
    cd /var/www/html/wiki/conf
    wget http://php-mobile-detect.googlecode.com/files/Mobile_Detect.php
  • 修改 inc/init.php 1)
    vi /var/www/html/wiki/inc/init.php
    • 在 72-77 行加入以下程式碼
      // for Mobile http://www.dokuwiki.org/template:dokumobile
      include(DOKU_CONF . "Mobile_Detect.php");
      $mdetect = new Mobile_Detect();
      if ($mdetect->isMobile()) {$conf['template']='dokumobile';}
    • 在原本 121-127 define Template baseURL, define real Template directory 要取消不執行
      #// define Template baseURL
      #if(!defined('DOKU_TPL')) define('DOKU_TPL',
      #        DOKU_BASE.'lib/tpl/'.$conf['template'].'/');
      
      #// define real Template directory
      #if(!defined('DOKU_TPLINC')) define('DOKU_TPLINC',
      #        DOKU_INC.'lib/tpl/'.$conf['template'].'/');
  • 如果透過 upgrade plugin 更版, 會將 inc/init.php 還原回預設版本
  • 因此在 dokuwiki 更版後如果無法自動切換 Mobile 呈現畫面,就需再次更改 inc/init.php

1)
原 dokumobile 網頁是修改 inc/local.php 但是如果透過 admin 介面修改參數, 就會將這修改 code 除去不見
  • tech/dokuwiki_mobile.txt
  • 上一次變更: 2012/05/01 17:31
  • jonathan