It is very convenient to configure elaborated element settings only once. Here, we provide to choose the wanted date format in the element settings. Then, this element setting can be used by any formatter.
It is not necessary to configure frequently used element settings in every formatter which they are used in. Once described in one configuration file, all element settings are accessible by calling their setting names.
Some element settings are needed in a number of formatters without any or little changes. To avoid the work to configure each time they are used, OpenCms allows you to define the element settings in one configuration file. Then, you can call the settings from your formatter in a few easy steps.
First, you need to create a configuration file for the common element settings. This can be done in the explorer view. There you can add via "Add-Wizard" a new resource of the type "Shared element settings" under the item "Configurations" in the dropdown list.
In this file you can add a new element settings as described here.
Now the element setting can be used in the tab "Supported settings" of any formatter configuration simply by using the Setting name
. Remember to link to the configuration file to make the default element settings available.
Now the configured element setting is available in the "Element settings" window, which you can open at the gear wheel , which appears when you hover over the edit point .
Sometimes, it is desired to have two slightly different element settings. But for reasons of consistency they shall have the same Setting name
in the formatter configuration, with which you call them in your JSP. Applied to the example above, you can limit the number of date formats to select, and still call the shortened list with the same EL annotation. This is enabled by the field Include name
in the formatter configuration.
At first, the alternative element setting is added to the configuration file.
The modified element setting can now be included to the formatter configuration by setting its name to the field Include name
.
The dropdown menu for the date format in the window "Element settings" now shows less options to choose, but in both cases, in the JSP the element setting is called by the annotation ${cms.element.settings.dateFormat}
.