devp-eu/tmcms-module-settings

TMCms 模块设置

dev-master 2018-08-25 16:19 UTC

This package is not auto-updated.

Last update: 2024-09-29 01:40:42 UTC


README

TMCms 模块设置

模块设置可用于任何其他模块的扩展。将此代码添加到任何其他 CmsModule 类中,您将为它提供设置,例如在 CmsClients 中

public function settings() { 
  echo ModuleSettings::requireTableForExternalModule(P, [ 
    'is_registration_enabled' => [ 
      'type' => 'checkbox', 
    ], 
  ]); 
} 

public function _settings() { 
  ModuleSettings::requireUpdateModuleSettings(P, [ 
    'is_registration_enabled' => [ 
      'type' => 'checkbox', 
      'value' => 1, 
    ], 
  ]);
}

在代码中获取设置值,使用

$module_name = 'clients';
$setting_key = 'is_registration_enabled';
$setting_value = ModuleSettings::getCustomSettingValue($module_name, $setting_key);

此外,您还可以在菜单文件中添加 'settings' => [] 以在管理面板中显示模块。