OpenCms Documentation

Common element settings

 Show GitHub edit links  Hide GitHub edit links
In OpenCms since: 11.0.0 Documented since: 11.0.0 Latest revision for: 11.0.0 Valid for OpenCms: 11.0.2

Frequently used element settings can be configured in one file, which is shared by various formatters. This way, you don't need to configure the element settings in every single formatter. In this demo we have an element whose formatter obtains his element settings from a configuration file, These settings need to be configured once there and can then used by any formatter referring to this file in its configuration. Therefore you only have to write which element setting should be used in the formatter.

The result

This example shows how simple it is to handle element settings, which are used by multiple formatters. The element shown here has four element settings. It gets three of them from a configuration file, to which all other formatters have access to. In addition, it has a fourth element setting logoPosition and changes the default value of the second element setting.


Some of my element settings originate from a configuration file, so many other formatters can use them the way I do

My default element settings come from the configuration file for common element settings. But I change the default value to trim this text in my configuraion file to 500 characters. Gathering i, moving waters thing. There evening fill under Image. Likeness whose divide over life so. Male don't fruit beast bring likeness, him morning. Cattle. Sea lights dominion all morning land unto upon land In. Given. Earth wherein lights be us she'd. ...

Dec 7, 2018


Example resources and the interesting spots

This is the configuration file with element settings. This example contains three element settings which are reused by the element above.

Now the formatter configuration can link to this file and use these setting defaults. Note, that the default value of the second element setting is overwritten. Moreover, a fourth element setting is added, which does not belong to the common element settings. In this case, it must be configured directly in the formatter configuration.

The made settings are visible in the tab "Supported setiings". There you refer to the common element settings by using their setting names.

The values of the element settings can be called in the JSP as usual with the EL annotation, e.g. ${cms.element.value.hideTitle}

Hover over the edit points and click the small gear wheel  that appears to edit the element settings. The window to edit the element settings, looks as follows:

You can improve this page

Please contribute your suggestions or comments regarding this topic on our wiki. For support questions, please use the OpenCms mailing list or go for professional support.