帳號登錄
帳號:
密碼:
記住我 | 忘記密碼 | 帳號註冊
網站導覽
模組開發 : XoopsModuleConfig
作者 elie 於 2010年08月11日 21:00:00 (4868 次閱讀)

原始出處 http://www.xoops.org/modules/mediawiki/index.php/Dev:$xoopsModuleConfig
 

XoopsModuleConfig 是一個全域變數,可以在模組內儲存與使用偏好設定。初始值是在模組內xoops_version.php。在包含mainfile.php 後就可以使用這個全域變數了。
xoops_version.php檔案中使用下面的方式定義設定值:

    $modversion['config'][1] = array(
        'name' => 'config_name',
        'title' => 'Title',
        'description' => 'Description',
        'formtype' => 'yesno',
        'valuetype' => 'int',
        'default' => 1);

或是:

    $modversion['config'][1]['name'] = 'config_name';
    $modversion['config'][1]['title'] = 'Title';
    $modversion['config'][1]['description'] = 'Description';
    $modversion['config'][1]['formtype'] = 'yesno';
    $modversion['config'][1]['valuetype'] = 'int';
    $modversion['config'][1]['default'] = 1;

可能的'formtype' 如下:

    'yesno'
    'select'
    'select_multi'
    'group'
    'group_multi'
    'textbox'
    'textarea'
    'user'
    'user_multi'
    'timezone'
    'language'
    'hidden'

可能的'valuetype' 如下:

    'int'
    'float'
    'text'
    'array'

當項目的formtype 是'multi_xxx' 時valuetype 就必須是'array'。
每個項目必須有不同的編號。如果你使用第一種方式的話就可以不用擔心編號的問題。
常用函式

   * To retrieve the value of the configuration variable:
   $xoopsModuleConfig['config_name']
   * Still need to figure out how to change the value and update it in the database.

注意:考慮到效能的問題,在$xoopsConfig 中只註冊必要的參數就好了。


可列印模式 轉寄給朋友

The XOOPS organisation ("XOOPS") is committed to protecting the privacy of users of the XOOPS.org sites.
The website used Ver.2.4.5 POWERED BY XOOPS PROJECT.