Modules in version 3.1+ support the use of a config.json file, that defines basic configuration settings for the module.
Note |
---|
Due to backwards compatibility with version 3.0, config.json files are not required but are strongly recommended as they may be required in future versions. |
Example
Code Block |
---|
language | javascript |
---|
title | /components/modules/my_module/config.json |
---|
|
{
"version": "1.0.0",
"name": "My Module Name",
"description": "A module like no other!",
"authors": [
{
"name": "Phillips Data, Inc.",
"url": "http://www.blesta.com"
}
],
"service": {
"name_key": "service_field_key"
},
"module": {
"row": "Signular Form of Module Row",
"rows": "Plural Form of Module Row",
"group": "Module Group Name",
"row_key": "module_row_field_key"
}
} |
Definition
Option | Description |
---|
version | The version of the module. This should be a semantic version number. |
name | The name of the module. This may also be a language definition. |
description | A brief description of the module. Note |
---|
Planned for future use. |
|
authors | An array of author objects. Option | Description |
---|
name | The name of the author. This may be a language definition | url | The URL to link to for the author. |
|
logo | The path within the module to the logo file. If not set, defaults to views/default/images/logo.png. |
service | An object of service settings. Option | Description |
---|
name_key | The value of service_fields.key used to identify a service's label (e.g. if your module registers domains, this might be domain). |
|
module | An object of module settings. Option | Description |
---|
row | The singular form of the noun used to describe a module row (e.g. if your module registers domain, this might be Registrar Account). This may also be a language definition. | rows | The plural form of the noun used to describe the module row (e.g. Registrar Accounts). This may also be a language definition. | group | The noun used to describe a collection of module rows (e.g. Registrar Accounts). This may also be a language definition. | row_key | The value of module_row_meta.key used to identify a module row. |
|
Using the Configuration
To use the configuration file you must include it within the constructor of your module using the loadConfig() method.
Code Block |
---|
language | php |
---|
title | /components/modules/my_module/my_module.php |
---|
linenumbers | true |
---|
|
<?php
class MyModule extends Module {
public function __construct() {
$this->loadConfig(dirname(__FILE__) . DS . "config.json");
}
}
?> |
If your configuration uses any language definitions, be sure to include those before loading the config.
Code Block |
---|
language | php |
---|
title | /components/modules/my_module/my_module.php |
---|
linenumbers | true |
---|
|
<?php
class MyModule extends Module {
public function __construct() {
Language::loadLang("my_module", null, dirname(__FILE__) . DS . "language" . DS);
$this->loadConfig(dirname(__FILE__) . DS . "config.json");
}
}
?> |