settings
Note
Watch a short video tutorial on YouTube: Module Settings.
- Description
In this section all module configuration options are registered. In the eShop admin, users can configure modules according these settings. The settings can be translated and you can access the values in your php code.
- Type
Array of associative arrays. Array keys:
Each module setting belongs to a group (key
group
). This key is mandatory to display the setting in the default module settings tab. If you want to hide it instead, see hiding settings for more information.The mandatory key
name
is used for getting and storing the setting. It is best practice to prefix it with your module id to avoid name collisions with other modules.The key
type
is mandatory. Possible values arestr
,bool
,num
(integer or float),arr
(array),aarr
(associative array),select
(multiple options, translation possible),password
. If type isselect
, you have to define the possible values by another keyconstraints
.The key
value
sets a default value and is also mandatory. The keystype
andvalue
have to fit, see example below.The optional parameter
position
sets the order of module settings shown in the eShop admin.
- Mandatory
No
- Usage
In PHP classes you can query your module settings with the settings bridge.
In templates you have to use the
Config
class:{% set oConfig = oViewConf.getConfig() %} {{ oConfig.getConfigParam('nameOfSetting') }}
Add translations of your module’s settings in each copy of the corresponding
module_options.php
file (see details in File and Folder structure).
Example
'settings' => [ /** Main */ // If type equals select, the key constraints has to specify possible values. [ 'group' => 'oemoduletemplate_main', 'name' => 'oemoduletemplate_GreetingMode', 'type' => 'select', 'constraints' => 'generic|personal', 'value' => 'generic' ], [ 'group' => 'oemoduletemplate_main', 'name' => 'oemoduletemplate_BrandName', 'type' => 'str', 'value' => 'Testshop' ], [ 'group' => 'oemoduletemplate_main', 'name' => 'oemoduletemplate_LoggerEnabled', 'type' => 'bool', 'value' => false ], [ 'group' => 'oemoduletemplate_main', 'name' => 'oemoduletemplate_Timeout', 'type' => 'num', 'value' => 30 //'value' => 30.5 ], [ 'group' => 'oemoduletemplate_main', 'name' => 'oemoduletemplate_Categories', 'type' => 'arr', 'value' => ['Sales', 'Manufacturers'] ], [ 'group' => 'oemoduletemplate_main', 'name' => 'oemoduletemplate_Channels', 'type' => 'aarr', 'value' => ['1' => 'de', '2' => 'en'] ], [ 'group' => 'oemoduletemplate_main', 'name' => 'oemoduletemplate_Password', 'type' => 'password', 'value' => 'changeMe', 'position' => 3 ] ]
Hiding settings
It is possible to hide module settings so they wouldn’t be displayed in module settings tab. This might be useful when you have custom settings page, but still want that the module would use all necessary OXID eShop functionality like storing settings data in project configuration files. More information about this feature please read modules configuration documentation).
You can hide module setting by simply not adding group
when describing setting in metadata.php
file.
Example
'settings' => [ [ 'name' => 'oemoduletemplate_BrandName', 'type' => 'str', 'value' => 'Testshop' ],