xoops_version.php - 模組清單
xoops_version.php 檔案是每個 XOOPS 模組的中心。它定義模組中繼資料、資料庫表、範本、區塊、組態選項和安裝掛鉤。
<?php/** * 模組清單檔案 */
$modversion = [ // 模組身分識別 'name' => _MI_MYMODULE_NAME, 'version' => '1.0.0', 'description' => _MI_MYMODULE_DESC, 'author' => 'Your Name', 'author_mail' => 'your@email.com', 'author_website' => 'https://yoursite.com', 'credits' => 'Contributors', 'license' => 'GPL 2.0 or later', 'license_url' => 'https://www.gnu.org/licenses/gpl-2.0.html', 'dirname' => basename(__DIR__),
// 圖片 'image' => 'assets/images/logo.png', 'modicons16' => 'assets/images/icons/16', 'modicons32' => 'assets/images/icons/32',
// 系統設定 'system_menu' => 1, 'hasAdmin' => 1, 'adminindex' => 'admin/index.php', 'adminmenu' => 'admin/menu.php', 'hasMain' => 1, 'hasSearch' => 1, 'hasComments' => 0, 'hasNotification'=> 0,];模組身分識別
Section titled “模組身分識別”| 鍵 | 型別 | 說明 |
|---|---|---|
name | 字串 | 顯示名稱 (使用語言常數) |
version | 字串 | 語義版本 (MAJOR.MINOR.PATCH) |
description | 字串 | 模組說明 |
author | 字串 | 主要作者名稱 |
credits | 字串 | 其他貢獻者 |
license | 字串 | 授權名稱 |
dirname | 字串 | 模組目錄名稱 |
$modversion['sqlfile']['mysql'] = 'sql/mysql.sql';
$modversion['tables'] = [ 'mymodule_items', 'mymodule_categories', 'mymodule_comments',];$modversion['templates'] = [ ['file' => 'mymodule_index.tpl', 'description' => 'Index page template'], ['file' => 'mymodule_item.tpl', 'description' => 'Single item view'], ['file' => 'mymodule_category.tpl', 'description' => 'Category listing'],];$modversion['blocks'][] = [ 'file' => 'blocks/recent.php', 'name' => _MI_MYMODULE_BLOCK_RECENT, 'description' => _MI_MYMODULE_BLOCK_RECENT_DESC, 'show_func' => 'mymodule_recent_show', 'edit_func' => 'mymodule_recent_edit', 'template' => 'mymodule_block_recent.tpl', 'options' => '10|0', // 預設選項 'can_clone' => true,];$modversion['config'][] = [ 'name' => 'items_per_page', 'title' => '_MI_MYMODULE_ITEMS_PER_PAGE', 'description' => '_MI_MYMODULE_ITEMS_PER_PAGE_DESC', 'formtype' => 'textbox', 'valuetype' => 'int', 'default' => 10,];
$modversion['config'][] = [ 'name' => 'enable_comments', 'title' => '_MI_MYMODULE_ENABLE_COMMENTS', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 1,];
$modversion['config'][] = [ 'name' => 'display_mode', 'title' => '_MI_MYMODULE_DISPLAY_MODE', 'description' => '', 'formtype' => 'select', 'valuetype' => 'text', 'default' => 'list', 'options' => [ _MI_MYMODULE_MODE_LIST => 'list', _MI_MYMODULE_MODE_GRID => 'grid', ],];| formtype | valuetype | 說明 |
|---|---|---|
textbox | text/int | 單行輸入 |
textarea | text | 多行輸入 |
yesno | int | 是/否廣播 |
select | text | 下拉式選擇 |
select_multi | array | 多重選擇 |
group | int | 群組選擇器 |
group_multi | array | 多群組選擇器 |
user | int | 使用者選擇器 |
color | text | 色彩選擇器 |
hidden | text | 隱藏欄位 |
// 主功能表$modversion['sub'][] = [ 'name' => _MI_MYMODULE_SMENU_INDEX, 'url' => 'index.php',];
$modversion['sub'][] = [ 'name' => _MI_MYMODULE_SMENU_SUBMIT, 'url' => 'submit.php',];$modversion['onInstall'] = 'include/oninstall.php';$modversion['onUpdate'] = 'include/onupdate.php';$modversion['onUninstall'] = 'include/onuninstall.php';$modversion['hasSearch'] = 1;$modversion['search'] = [ 'file' => 'include/search.php', 'func' => 'mymodule_search',];$modversion['hasComments'] = 1;$modversion['comments'] = [ 'itemName' => 'item_id', 'pageName' => 'item.php',];$modversion['hasNotification'] = 1;$modversion['notification'] = [ 'lookup_file' => 'include/notification.php', 'lookup_func' => 'mymodule_notify_iteminfo', 'category' => [ [ 'name' => 'global', 'title' => _MI_MYMODULE_NOTIFY_GLOBAL, 'description' => '', 'subscribe_from' => 'index.php', ], [ 'name' => 'item', 'title' => _MI_MYMODULE_NOTIFY_ITEM, 'description' => '', 'subscribe_from' => 'item.php', 'item_name' => 'item_id', ], ], 'event' => [ [ 'name' => 'new_item', 'category' => 'global', 'title' => _MI_MYMODULE_NOTIFY_NEW_ITEM, 'caption' => _MI_MYMODULE_NOTIFY_NEW_ITEM_CAP, 'mail_template' => 'notify_newitem', 'mail_subject' => _MI_MYMODULE_NOTIFY_NEW_ITEM_SUBJ, ], ],];- Module-Development - 完整模組指南
- Module-Structure - 目錄結構
- Block-Development - 建立區塊
- Database-Operations - 資料庫設定