• Developer guides

Manager settings

Includable Modules can create a settings screen under the Modules section in the Includable Manager.

Setting up

Settings are specified in the module.json file:

{
    ...,

    "settings": [
        {
            "type": "group",
            "title": "RSS feed source"
        },
        {
            "id": "source",
            "type": "text",
            "placeholder": "http://example.com/feed.rss",
            "title": "RSS feed URL"
        },
        {
            "id": "cachetimeout",
            "type": "number",
            "min": 1,
            "default": 15,
            "title": "Refresh every (minutes)"
        },
        {
            "id": "showavg",
            "type": "select",
            "values": {
                "no": "Hide averages",
                "yes": "Show averages"
            },
            "title": "Average grades",
            "default": "yes"
        }
    ],

    ...
}

Defining settings

Available types

  • text – single line text field
  • textarea – multi line text field
  • number – number field (supports parameters min, max and step as described in the HTML5 spec)
  • password – masked password field
  • select – select box (options are specified in parameter values)
  • checkbox – simple checkbox (display value is specified in parameter label – default is ‘Activate’)
  • color – HTML color code picker
  • group – Group header section

Default parameters

These parameters apply to all setting types.

  • title – The setting display name (required)
  • description – Helper text shown above input (optional)
  • default – Default value for setting (not supported for type group)

Retrieving settings

Retrieving settings is really simple:

// Retrieve setting with ID 'source':
$value = $this->settings->source;