跳至主內容區

XOOPS輕鬆架

:::

主內容區域

選擇後會自動跳轉頁面

4-2 將資料送至樣板呈現

 一、關於XOOPS的樣板引擎

  1. XOOPS的樣板引擎是使用 smarty 2.6.x(所以,新的 smarty 3.x 語法無法使用)
  2. 樣板引擎物件為 $xoopsTpl
  3. 套用變數到樣板的語法為
    $xoopsTpl->assign('樣板變數名稱' , $PHP變數);
  4. 在樣板中,則是使用以下方式來呈現變數:
    <{$樣板變數名稱}>

二、將表單輸出到畫面

  1. 簡單整理一下架構:
    //顯示預設頁面內容
    function action_form()
    {
        global $xoopsTpl;
    
        include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
        $val = ['title' => '', 'action_date' => date('Y-m-d'), 'end_date' => date('Y-m-d 17:30:00'), 'enable' => '1', 'content' => ''];
    
        $form = new XoopsThemeForm('編輯活動', 'name', 'main.php', 'post', true);
        //各種表單元件
        $action_form = $form->render();
    
        $xoopsTpl->assign('action_form', $action_form);
    }
  2. 最後套入 templates/tad_signup_adm_main.tpl 樣板檔:
    <div class="container-fluid">
      <{$action_form}>
    </div>

選擇後會自動跳轉頁面

:::

左邊區域內容

書籍目錄

展開 | 闔起

快速登入


右邊區域內容

請掃此 QR Code 可連至此頁面

計數器

今天: 1313
昨天: 2475247524752475
總計: 9512797951279795127979512797951279795127979512797

頁尾區域