Custom plugin settings UI

How to create the settings page for a Shop-Script 6 plugin

Contents...

If a plugin requires additional setup by a user, then all necessary settings fields must be specified in plugin configuration file lib/config/settings.php Creation of such a file for automatic generation of standard plugin settings interface is described in a separate article.

Custom settings page

Should you need to create a settings page completely different from the standard one suggested by Shop-Script, add the following parameter to configuration file plugin.php:

'custom_settings' => true,

PHP code for generation of the settings page must be written inside public method execute() of class named shop[Plugin_id]PluginSettingsAction extending base class waViewAction and located in file lib/actions/shop[Plugin_id]PluginSettings.action.php.

Accessing settings values

In the main plugin class you can access current settings values by calling method $this->getSettings() and specifying the id of the desired settings field as its parameter:

$login = $this->getSettings('login');

For fields of type GROUPBOX, only the array of values is saved which have been selected (enabled) by user. Their list can be retrieved in the following way:

$statuses = $this->getSettings('statuses');
$statuses = $statuses ? array_keys($statuses) : null;

The values of individual subfields of a CONTACT type field can be retrieved via the values of 'value' elements specified in the 'options' array for such a settings field:

$personal_data = $this->getSettings('personal_data');
$email = $personal_data['email'];