Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: fix anchors phase 2

...

Info

This is an advanced topic.

It is not necessary to use a model in Magnolia templating, but it is useful. If you are starting out with Magnolia use templating functions instead of a model. Model classes cannot be added to light modules because light modules cannot contain their own Java classes. However, a light module can reference a component model from another module such as MTE.

A model can execute any Java code to retrieve data from the JCR repository or from an external source.

...

All of the model's public methods can be accessed by the template script.

Benefits of using a model

...

Localtab Group
Localtab
activetrue
titleYAML file
Code Block
languagejs
title/my-module/templates/pages/home.yaml
renderType: freemarker 
templateScript: /my-module/templates/pages/home.ftl
dialog: my-module:pages/homePageProperties
modelClass: com.example.templates.HomePageModel
Localtab
titleJCR node
Advanced Tables - Table Plus
heading0
multiplefalse
enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse
Node nameValue
Mgnl f
my-module
 

Mgnl f
templates

 


Mgnl f
pages

 


Mgnl n
home

 


Mgnl p
dialog

my-module:pages/home.ftl

Mgnl p
modelClass

com.example.templates.HomePageModel

Mgnl p
renderType

freemarker

Mgnl p
templateScript

/my-module/templates/pages/home.ftl

...