不用修改) ```
  
  
  getByDirname("tncu_cart");
  $module_id = $xoopsModule->getVar('mid');
  
  $isAdmin=false;
  if ($xoopsUser){
    //判斷是否對該模組有管理權限
    $isAdmin=$xoopsUser->isAdmin($module_id);
  }
  $gperm = get_gperm($module_id,$isAdmin,$gperm_itemid_arr,$gperm_name_arr);
  //---- 權限設定 ---- */
  
  #工具列設定
  $mod_name   = $xoopsModule->name();//模組中文名
  $module_name = $xoopsModule->dirname();//模組
  
  $moduleMenu = array();
  if($gperm['tncu_cartAdmin'][4]){  
    $i = 0;
    $moduleMenu[$i]['url']="index.php";
    $moduleMenu[$i]['title']="回首頁";
    $moduleMenu[$i]['icon']="fa-home";
    
    $i++;
    $moduleMenu[$i]['url']="menu.php";
    $moduleMenu[$i]['title']="選單管理";
    $moduleMenu[$i]['icon']="fa-bars";
  }
  
  if($isAdmin) {
    $i++;
    $moduleMenu[$i]['url']="admin/index.php";
    $moduleMenu[$i]['title']=sprintf(_TAD_ADMIN,$mod_name);//管理後台
    $moduleMenu[$i]['icon']="fa-wrench";
    $i++;
    $moduleMenu[$i]['url']=XOOPS_URL."/modules/system/admin.php?fct=preferences&op=showmod&mod={$module_id}";
    $moduleMenu[$i]['title']=sprintf(_TAD_CONFIG,$mod_name);//」偏好設定
    $moduleMenu[$i]['icon']="fa-edit";
    $i++;
    $moduleMenu[$i]['url']=XOOPS_URL."/modules/system/admin.php?fct=modulesadmin&op=update&module={$module_name}";
    $moduleMenu[$i]['title']=sprintf(_TAD_UPDATE,$mod_name);//更新
    $moduleMenu[$i]['icon']="fa-refresh";
    $i++;
    $moduleMenu[$i]['url']=XOOPS_URL."/modules/system/admin.php?fct=blocksadmin&op=list&filter=1&selgen={$module_id}&selmod=-2&selgrp=-1&selvis=-1";
    $moduleMenu[$i]['title']=sprintf(_TAD_BLOCKS,$mod_name);//」區塊管理
    $moduleMenu[$i]['icon']="fa-th";
  
  }
  ```
4. 
 
二、自動更新,增加資料表
1. include/onInstall.php  
   go\_update() ```
  
  
    //資料表      
    #---- 增加資料表 tncu_cart_kind
    $tbl = "tncu_cart_kind";
    if(!chk_isTable($tbl)){
      $sql="
        CREATE TABLE `" . $xoopsDB->prefix($tbl) . "` (
          `sn` smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT 'sn',
          `ofsn` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '父類別',
          `kind` varchar(255) NOT NULL DEFAULT 'prod' COMMENT '分類',
          `title` varchar(255) NOT NULL DEFAULT '' COMMENT '標題',
          `sort` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
          `enable` enum('1','0') NOT NULL DEFAULT '1' COMMENT '狀態',
          `url` varchar(255) NOT NULL DEFAULT '' COMMENT '網址',
          `target` enum('1','0') NOT NULL DEFAULT '0' COMMENT '外連',
          `col_sn` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'col_sn',
          `content` text COMMENT '內容',
          `ps` varchar(255) DEFAULT NULL COMMENT '備註',
          PRIMARY KEY (`sn`)
        ) ENGINE=InnoDB;
      ";
      $xoopsDB->queryF($sql);
    } 
  ```
2. sql/mysql.sql (安裝模組時使用,如使用InnoDB,則要注意關聯) ```
  
  
  -- 2
  CREATE TABLE `tncu_cart_kind` (
    `sn` smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT 'sn',
    `ofsn` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '父類別',
    `kind` varchar(255) NOT NULL DEFAULT 'prod' COMMENT '分類',
    `title` varchar(255) NOT NULL DEFAULT '' COMMENT '標題',
    `sort` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
    `enable` enum('1','0') NOT NULL DEFAULT '1' COMMENT '狀態',
    `url` varchar(255) NOT NULL DEFAULT '' COMMENT '網址',
    `target` enum('1','0') NOT NULL DEFAULT '0' COMMENT '外連',
    `col_sn` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'col_sn',
    `content` text COMMENT '內容',
    `ps` varchar(255) DEFAULT NULL COMMENT '備註',
    PRIMARY KEY (`sn`)
  ) ENGINE=InnoDB;
  ```
3. xoops\_version.php ```
  
  
  $modversion['tables'][2] = 'tncu_cart_kind';
  ```
 
三、選單管理
  
1. xoops\_version.php ```
  
  
  $i++;
  $modversion['templates'][$i]['file']        = 'tncu_cart_menu.tpl';
  $modversion['templates'][$i]['description'] = 'tncu_cart_menu.tpl';
  ```
2. menu.php ```
  
  path('/modules/system/include/functions.php');
  $op = system_CleanVars($_REQUEST, 'op', '', 'string');
  $sn = system_CleanVars($_REQUEST, 'sn', '', 'int');
  $kind = system_CleanVars($_REQUEST, 'kind', 'menuMain', 'string'); 
  
  #foreign key
  $foreign = array(
    "menuMain" => array("title" => "主選單", "stopLevel" => 3),
  );
  
  #防呆
  $kind = in_array($kind, array_keys($foreign))?$kind:"menuMain";
  
  #關閉左右區塊
  $xoopsTpl->assign( 'xoops_showlblock', 0 );
  $xoopsTpl->assign( 'xoops_showrblock', 0 );
  
  #引入列表與表單陣列-----------------------
  require_once XOOPS_ROOT_PATH . "/modules/ugm_tools2/ugm_kind3_menuArray.php";
  
  #引入類別物件---------------------------------
  require_once XOOPS_ROOT_PATH . "/modules/ugm_tools2/ugm_kind3_main.php";
  
  
  ###########################################################
  #  異動後,要執行的動作
  ###########################################################
  function transaction(){
    global $xoopsDB, $ugmKind,$op;
    #---- 過濾讀出的變數值 ----
    $myts = MyTextSanitizer::getInstance();
    $kind = $ugmKind->get_kind();
    $moduleName =$ugmKind->get_moduleName();
    $stopLevel =$ugmKind->get_stopLevel();
    $ofsn=0;
    $level=1;
    $enable=1;
  
    if($kind == "menuMain"){
    }
  }
  
  ###########################################################
  #  刪除資料 額外檢查
  ###########################################################
  function opDeleteCheck($sn = "") {
    global $xoopsDB, $ugmKind;
  }
  ```
3. tncu\_cart\_menu.tpl ```
  
  <{includeq file="$xoops_rootpath/modules/ugm_tools2/templates/ugm_tools_toolbar.tpl"}>
  
  <{if $op=="opList"}>
    
    
    
  
    
    
    
  
    
    
  <{/if}>
  
  
  <{if $op=="opForm"}>
    
    
    
    
    
    
  <{/if}>
  
  
  
  
  
  
  
  
  
  ```