:::

5-3-1 建立後台頁面 main.php

您沒有觀看影片的權限

您沒有觀看影片的權限

請先登入,登入後,確認您的權限後,即可觀看影片。

  1. 從後台的 admin/menu.php 我們可以看見預設有三個頁面,其中 index.phpabout.php 是預設就有的,若想新增其餘頁面,必須先至此檔多一組設定。
    <?php
    $adminmenu[] = ['title' => _MI_TAD_ADMIN_HOME, 'link' => 'admin/index.php', 'icon' => 'images/admin/home.png'];
    $adminmenu[] = ['title' => '活動管理', 'link' => 'admin/main.php', 'icon' => 'images/admin/button.png'];
    $adminmenu[] = ['title' => _MI_TAD_ADMIN_ABOUT, 'link' => 'admin/about.php', 'icon' => 'images/admin/about.png'];
    

     

  2. 接著開啟 admin/main.php,借用index.php的內容,把需要的流程及設定複製過來即可。
    <?php
    use Xmf\Request;
    use XoopsModules\Tad_signup\Tad_signup_actions;
    
    /*-----------引入檔案區--------------*/
    $GLOBALS['xoopsOption']['template_main'] = 'tad_signup_admin.tpl';
    require_once __DIR__ . '/header.php';
    require_once dirname(__DIR__) . '/function.php';
    $_SESSION['tad_signup_adm'] = true;
    
    /*-----------變數過濾----------*/
    $op = Request::getString('op');
    $id = Request::getInt('id');
    
    /*-----------執行動作判斷區----------*/
    switch ($op) {
    
        //新增活動表單
        case 'tad_signup_actions_create':
            Tad_signup_actions::create();
            break;
    
        //新增活動資料
        case 'tad_signup_actions_store':
            $id = Tad_signup_actions::store();
            // header("location: {$_SERVER['PHP_SELF']}?id=$id");
            redirect_header($_SERVER['PHP_SELF'] . "?id=$id", 3, "成功建立活動!");
            exit;
    
        //修改用表單
        case 'tad_signup_actions_edit':
            Tad_signup_actions::create($id);
            $op = 'tad_signup_actions_create';
            break;
    
        //更新資料
        case 'tad_signup_actions_update':
            Tad_signup_actions::update($id);
            // header("location: {$_SERVER['PHP_SELF']}?id=$id");
            redirect_header($_SERVER['PHP_SELF'] . "?id=$id", 3, "成功修改活動!");
            exit;
    
        //刪除資料
        case 'tad_signup_actions_destroy':
            Tad_signup_actions::destroy($id);
            // header("location: {$_SERVER['PHP_SELF']}");
            redirect_header($_SERVER['PHP_SELF'], 3, "成功刪除活動!");
            exit;
    
        default:
            if (empty($id)) {
                Tad_signup_actions::index();
                $op = 'tad_signup_actions_index';
            } else {
                Tad_signup_actions::show($id);
                $op = 'tad_signup_actions_show';
            }
            break;
    }
    
    /*-----------功能函數區----------*/
    
    /*-----------秀出結果區--------------*/
    $xoopsTpl->assign('now_op', $op);
    $xoTheme->addStylesheet('/modules/tadtools/css/font-awesome/css/font-awesome.css');
    $xoTheme->addStylesheet(XOOPS_URL . '/modules/tadtools/css/xoops_adm4.css');
    $xoTheme->addStylesheet(XOOPS_URL . '/modules/tad_signup/css/module.css');
    require_once __DIR__ . '/footer.php';
    

     

  3. 已經完工囉!

link to https://github.com/tadlearn/tad_signup/commit/0405ae683a6ce606a81fabfd1f3fdc76fc14c6ae \


:::

搜尋

QR Code 區塊

https%3A%2F%2Fwww.tad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D48%26tbdsn%3D1692

書籍目錄

展開 | 闔起

線上使用者

19人線上 (3人在瀏覽線上書籍)

會員: 0

訪客: 19

更多…