線上書籍

Home

八小時模組開發

一、 前台結構
  1. 前台的結構如下: <?php /* index.php 是模組的預設首頁(入口)。 若前台還有需要別的檔案,可以直接複製此檔然後改名即可。 */ /*------------------ 檔頭(引入檔案) ------------------*/ //引入共同檔案設定檔及共同函數檔 function.php(必要) include "header.php"; //使用樣板檔 $xoopsOption['template_main'] = "前台樣板檔.html"; //引入XOOPS前台檔案檔頭(必要) include_once XOOPS_ROOT_PATH."/header.php"; /*------------------ 流程判斷(告訴程式現在要做什麼) -----------------*/ //$op 為XOOPS常用之動作變數,用來告知程式欲執行之動作 $op=isset($_REQUEST['op'])?$_REQUEST['op']:""; //判斷目前動作該執行哪一個 switch($op){ //當 $op 的值等於「動作1」時,欲執行的動作 case "動作1": do_something(); break; //預設動作 default: break; } /*------------------ 所有函數(實際執行動作) ------------------*/ //當 $op 的值等於「動作1」時,欲執行的函數 function do_something(){ } /*------------------ 檔尾(輸出內容到樣板) ------------------*/ //套用工具列的程式碼到樣板檔(toolbar_bootstrap()來自tadtools函式庫) $xoopsTpl->assign( "toolbar" , toolbar_bootstrap($interface_menu)) ; //套用 bootstrap 的引入語法到樣板檔(get_bootstrap()來自tadtools函式庫) $xoopsTpl->assign( "bootstrap" , get_bootstrap()) ; //套用 jquery 的引入語法到樣板檔(get_jquery()來自tadtools函式庫) $xoopsTpl->assign( "jquery" , get_jquery(true)) ; //將「是否為該模組管理員」的變數傳送到樣板檔($isAdmin來自header.php檔) $xoopsTpl->assign( "isAdmin" , $isAdmin) ; //引入XOOPS前台檔案檔尾(必要) include_once XOOPS_ROOT_PATH.'/footer.php'; ?>
  2. 一定要引入:include_once '../../mainfile.php'; (已包含在 header.php 中)
  3. 頁首:include_once XOOPS_ROOT_PATH."/header.php";
  4. 頁尾:include_once XOOPS_ROOT_PATH.'/footer.php';
  5. 其餘結構可比照後台頁面結構。
二、 前台主選單設定
  1. 有前台時,記得到xoops_version.php去加入 $modversion['hasMain'] = 1;
  2. 若前台有好幾個子功能,可以在主選單中加入子選項:
  3. $modversion['sub'][1]['name'] = '子選項名稱';
  4. $modversion['sub'][1]['url'] = '連結位置';
三、建立頁面的專屬樣板檔
  1. index.php 中的 $xoopsOption['template_main'] 請設定一個網頁樣板檔: //使用樣板檔 $xoopsOption['template_main'] = "my_dict_index.html";
  2. xoops_version.php 要加入一個樣板設定,這樣 XOOPS 才知道要載入您的樣板檔: $modversion['templates'][$i]['file'] = 'my_dict_index.html'; $modversion['templates'][$i]['description'] = 'my_dict_index.html';
  3. 實際去生出 my_dict_index.html ,樣板檔一律放在 templates 下。
  4. 其內容可以先這樣建立: <{$bootstrap}> <{$jquery}> <{$toolbar}> <h1>簡易英漢字典</h1>
  5. 其中 <{$bootstrap}> 等三個樣板標籤是在 index.php頁面中就會幫您做好的部份,目的是用來載入 BootStrap 框架。此設定可在 tadtools 模組的台首頁設定是否載入bootstrap(如果是tad系列佈景,預設無需載入)
  6. <{$jquery}> 則是用來載入 jquery,此項目可在 tadtools 的偏好設定決定要以何種方式載入。
  7. <{$toolbar}> 則是用來載入模組工具列,其工具列選項可以在模組中 header.php 裡面設定(即新增一組 $interface_menu 設定即可,索引為「呈現的選項文字」,值則是填入頁面、網址即可。)

 

四、上次進度模組下載

my_dict.zip