Page tree
Skip to end of metadata
Go to start of metadata

Autogeneration creates components inside an area automatically, without editor involvement. Anything you define inside the content item will be autogenerated. 

Autogeneration behavior

Autogenerated components behave different from normal components:

  • Ordered as defined: In an empty area, components are autogenerated in the same order as they are defined in the area definition.
  • New components are placed last: If an area already has autogenerated components, newly defined components will be placed last.
  • Cannot delete permanently: When you delete autogenerated component, it is regenerated and placed last in the area.

Autogeneration properties

Configure component autogeneration in an area definition, under the autoGeneration item. Simple example:

areas:
  footer:
    renderType: freemarker
    type: single
    autoGeneration:
      content:
        quotation:
          nodeType: mgnl:component
          templateId: my-module:components/quotation
          quotationText: <p>Carpe diem.</p>
          citedPerson: Horace
      generatorClass: info.magnolia.rendering.generator.CopyGenerator
Node nameValue

 areas

 

 footer

 

 autoGeneration

 

 content

 

 quotation

 

 citedPerson

Horace

 nodeType

mgnl:component

 quotationText

<p>Carpe diem.</p>

 templateId

my-module:components/quotation

 generatorClass

info.magnolia.rendering.generator.CopyGenerator

 renderType

freemarker

 type

single

Properties under autogeneration:

content

required

Parent item for autogenerated content. Put everything you want to autogenerate inside this item.

<component name>

required

nodeType

required

Value mgnl:component defines the referenced item as a component and generates a component node.

templateId

required

Component ID in <module>:<path> format that references a component definition .

generatorClass

required , default is info.magnolia.rendering.generator.CopyGenerator

A generator creates nodes based on the definition. The default CopyGenerator creates a copy of the exact nodes and properties you define under the content item. You can implement a custom generator class that does something else. Implement the Generator interface.