Versions Compared

Key

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

Table of Contents

 

Goals

  • To learn about a Magnolia mechanism that allows altering existing configured items
  • To learn the pattern for decorating definitions

Definition Decorator

  • Magnolia mechanism that allows you to alter existing configured items
  • Allows you to change the properties and sub-definitions of an existing definition

Concept of Definition Decoration 

  • Possible to change definitions such as app descriptors, dialogs, field types, templates, renderer definitions and more
  • The definition to be decorated can originate from any source, including the JCR and YAML files
  • Decorators themselves can only be defined via YAML for the time being
  • The effect of a decorator addition, removal or modification is visible on the next decorated definition retrieval attempt ... that is, you won't see the result of the decoration until you request the page again
  • Definition decorators are updated, registered and deregistered in real time, without the necessity of a server restart

Definition Decorator File Location

  • Definition decorator files must be stored in the decorations folder of a module
  • Definition decorator files are loaded in the same way as any other Magnolia resource

The pattern to decorate definitions:

Mgnl mini code snippet

<decorating-module-name>/decorations/<target-module-name>/<definition-type>/<definition-relative-path>/<definition-name>.yaml

Example of decorating a definition:

Mgnl mini code snippet

/training-templating-essentials/decorations/pages/apps/pages.yaml

Dissecting what each path means:
<decorating-module-name>

Module which declares the definition decorator.

  decorationsDecorations folder within the decorating module.
    <target-module-name>Name of the module that hosts the items targeted for decoration.
      <definition-type>Title of the registry containing definitions: e.g., apps, dialogs, templates and renderers.
        <def-relative-path>Path to the decorated definition within the target module, such as /pages or /components (for templates).
          <def-name>Name of the decorated definition, e.g. pages for the name of an app.


          

...

Page Turner
button-linkstrue

...