You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 19 Next »

A Magnolia light module is a file and folder-based module. It can define every Magnolia item which can be configured in YAML – such as apps, templates, dialogs, themes, and others. It can also contain a lightweight YAML-based module descriptor and web resources such as css and javascript files.

Light modules can be built with a simple text editor, with no special tools (such as Maven) required. A light module cannot incorporate java classes.

Light module structure

Below you see the structure of an exemplary light module. 

magnolia.resources.dir/
└── <module-name>/
    ├── apps/
    ├── dialogs/
    │   └── myDialog.yaml
    ├── module.yaml
    ├── webresources/
    └── templates/
        ├── components/
        │   ├── myComponent.ftl
        │   └── myComponent.yaml
        └── pages/
            ├── myTemplate.ftl
            └── myTemplate.yaml

Light modules can contain more or less folders compared to this example.

The magnolia.resources.dir - the light modules folder

Please note that a Magnolia Light module must reside within the so called "magnolia resources directory", the directory also often is referred as the Magnolia light modules folder. The name and the location of this directory are arbitrary - but you have provide the path to the folder via configuration.

magnolia.resources.dir is a property defining the directory from which resources are loaded in a Magnolia instance. This directory is used for file-based resources such as light modules and for overriding classpath resources. The property is configured in WEB-INF/config/default/magnolia.properties and has the default value $magnolia.home/modules. To see the current value of the property, go to the Config Info tab in the About Magnolia app.
(info) You can use symbolic links (a.k.a symlinks or soft links) in the resources directory to include light modules located elsewhere on your system.

What items can be defined in a light module?

The following items all can be defined within a light module with YAML. Items defined by YAML can be decorated, or they can be reused with YAML inherit and include

Other non YAML based items which can be in a light module:

Creating a light module with Magnolia CLI

With Magnolia CLI you can create the complete light module structure with a single command. (If you want to install CLI, see Magnolia CLI - Installation.)

Open a shell, change to you the light modules folder and run the following command:

mgnl create-light-module my-module

Instead of my-module use an appropriate name (no special characters such as space or german umlaut).


#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))
  • No labels