Configuring the moduleΒΆ

Global configuration variables for the site may be defined in the config element of module.xml. Values for these settings can be filled in when you edit the site in the admin console.

    <field-set name="info">
        <input type="TextLine" name="company">
          <occurrences minimum="1" maximum="1"/>
        <input type="TextArea" name="description">
          <occurrences minimum="1" maximum="1"/>

The company and description fields may now be filled out by editing the site. The values will be used in a standard footer for each page.


To use the module configuration values, the controller must retrieve the config element for the module and pass it to the Thymeleaf rendering method.

// Get the current site.
var site = execute('portal.getSite');

// Find the module configuration for this module in current site.
var moduleConfig = site.moduleConfigs['com.enonic.first.module'];

// Get the current content. It holds the context of the current execution
// session, including information about regions in the page.
var content = execute('portal.getContent');

// Include info about the region of the current content in the parameters
// list for the rendering.
var mainRegion =["main"];

// Extend the model from previous example
var model = {
    name: "Michael",
    mainRegion: mainRegion,
    moduleConfig: moduleConfig

Now we can update my-first-page.html file to render the configuration values that were passed from the controller.

<!DOCTYPE html>
    <h1>My first page, with a view!</h1>
    <h2>Hello <span data-th-text="${name}">World</span></h2>
    <footer id="footer">
        &copy; 2015
        <span data-th-text="${moduleConfig['company']}">My Company</span> -
        <span data-th-text="${moduleConfig['description']}">All Rights Reserved</span>