...
It is possible to change definitions such as app descriptors, dialogs, field types, message views, templates, media editors and renderer definitions. Any definition bound to a
Javadoc |
---|
0 | info.magnolia.config.registry.Registry |
---|
rangeHigherVersion | 5.7 |
---|
className | info.magnolia.config.registry.Registry |
---|
renderType | asynchronous |
---|
|
such as
Javadoc |
---|
0 | info.magnolia.rendering.template.registry.TemplateDefinitionRegistry |
---|
rangeHigherVersion | 5.7 |
---|
className | info.magnolia.rendering.template.registry.TemplateDefinitionRegistry |
---|
renderType | asynchronous |
---|
|
can be decorated.
Decorated definitions can originate from any source, including the JCR, YAML files or even executable code like Blossom. However, decorators themselves can only be defined via YAML for the time being.
Image Modified
Info |
---|
|
The same definition can be decorated multiple times. When a definition is decorated several times, the decorators are applied in the following order: - Decorators from Magnolia Maven modules* are applied before decorators from light modules.
- If there are decorators from different Magnolia Maven modules, they are applied in the dependency order of modules declaring the decorators. **
- If there are decorators from different Magnolia light modules, the application order can be unpredictable. You can make it predictable by defining the module loading order of your light modules in the module descriptor.
When two decorators are decorating the same part of a definition, the last decoration applied "wins". |
*) A Magnolia Maven module is a Maven packaged module which contains a Magnolia Module descriptor.
**) The Module descriptor defines Module dependencies. If module-a
depends on module-b
, module-b is loaded before module-a. The module dependencies of all Magnolia Maven modules together define a distinct order.
Decorating for merging or overriding
Info |
---|
Definition decoration changes properties and subdefinitions of an existing definition item. This change can either merge the decoration with the decorated definition or completely override it. In the latter case, you must use the !override directive. |
Have a look at Changing the cssFiles
property in the mtk page template basic
for examples of both merging and overriding.
Definition decorator file location
...
Magnolia maven module | Light module |
---|
my-maven-module/
└── src
└── main
└── resources
└── my-module
└── decorations
├── dam-app
│ └── apps
│ └── assets.subApps.browser.contentConnector.yaml
├── mtk
│ └── templates
│ └── pages
│ ├── basic.cssFiles.yaml
│ └── basic.yaml
└── pages
└── apps
└── pages.yaml |
$magnolia.resources.dir
└── my-module
└── decorations
├── dam-app
│ └── apps
│ └── assets.subApps.browser.contentConnector.yaml
├── mtk
│ └── templates
│ └── pages
│ ├── basic.cssFiles.yaml
│ └── basic.yaml
└── pages
└── apps
└── pages.yaml |
...
Change the title and the icon of an app
Code Pro |
---|
language | jsyml |
---|
title | /my-module/decorations/pages/apps/pages.yaml |
---|
|
label: My pages ...
icon: icon-user-me |
...
Change the root path of the content connector of the assets app
Code Pro |
---|
language | jsyml |
---|
title | /my-module/decorations/dam-app/apps/dam-app/assets.subApps.browser.contentConnector.yaml |
---|
|
rootPath: /cars/007-cars |
Result:
Image Modified
(Screenshot was taken from the definition-app which shows definition items read from the corresponding registry.)
Add a css file to the mtk page template basic
Code Pro |
---|
language | js |
---|
title | /my-module/decorations/mtk/templates/pages/basic.yaml |
---|
|
cssFiles:
chmStyles:
link: /.resources/my-module/css/chm-style.css |
...
Anchor |
---|
| anc-changing-cssFiles-in-a-pageTemplate |
---|
| anc-changing-cssFiles-in-a-pageTemplate |
---|
|
Changing the cssFiles
property in the mtk page template basic
Code Pro |
---|
language | jsyml |
---|
title | /my-module/decorations/mtk/templates/pages/basic.cssFiles.yaml |
---|
|
chmStyles:
link: /.resources/my-module/css/chm-style.css |
Overriding properties and changing subitems
Note |
---|
Please note that you can override properties, but you cannot override a subitem completely. You only can add new properties or subitems to an existing subitem. |
To understand the above statement, let's have a look at an example of a (simplified) template definition:
|
Code Pro |
---|
|
templateScript: /mtk/templates/pages/basic.ftl
dialog: mtk:pages/basic
renderType: freemarker
class: info.magnolia.module.templatingsite.definitiontemplates.PageTemplateDefinition
cssFiles:
normalize:
link: /.resources/mtk/webresources/css/normalize-3.0.3.css
main:
link: /.resources/mtk/webresources/css/html5boilerplate-main-5.3.0.css
video:
link: /.resources/mtk/webresources/css/video.css |
Here you can completely override the properties templateScript
, dialog
, renderType
, class
and link
, but you cannot completely override the cssFiles
subItem. For subitems you can only can add more properties and subItems.
...
The original template defines three CSS files.
a) Adding an additional CSS file - merging
Code Pro |
---|
language | yml |
---|
title | /my-module/decorations/mtk/templates/pages/basic.yaml |
---|
|
cssFiles:
minimum:
link: /.resources/my-module/webresources/css/minimum.css |
Image Added
b) Overriding the property completely - using !override
Code Pro |
---|
language | jsyml |
---|
title | /my-module/decorations/mtk/templates/pages/basic.cssFiles.yaml |
---|
|
normalizecssFiles: !override
minimum:
link: ""/.resources/my-module/webresources/css/minimum.css |
Image Added