Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
0info.magnolia.config.registry.Registry
rangeHigherVersion6.0
classNameinfo.magnolia.config.registry.Registry
renderTypeasynchronous
 such as
Javadoc
0info.magnolia.rendering.template.registry.TemplateDefinitionRegistry
rangeHigherVersion6.0
classNameinfo.magnolia.rendering.template.registry.TemplateDefinitionRegistry
renderTypeasynchronous
 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
iconfalse

The same definition can be decorated multiple times. When a definition is decorated several times, the decorators are applied in the following order:

  1. Decorators from Magnolia Maven modules* are applied before decorators from light modules.
  2. If there are decorators from different Magnolia Maven modules, they are applied in the dependency order of modules declaring the decorators. **
  3. 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 moduleLight 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
languagejsyml
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
languagejsyml
title/my-module/decorations/dam-app/apps/dam-app/assets.subApps.browser.contentConnector.yaml
rootPath: /cars/007-cars

...

(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
languagejs
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
languagejsyml
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:

(excerpt)
collapsetrue
Code Pro
languagejs
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 templateScriptdialogrenderTypeclass 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
languageyml
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
languagejsyml
title/my-module/decorations/mtk/templates/pages/basic.cssFiles.yaml
normalizecssFiles: !override
  minimum:
    link: ""/.resources/my-module/webresources/css/minimum.css

Image Added