Magnolia 5.3 reached end of life on June 30, 2017. This branch is no longer supported, see End-of-life policy.

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

This tutorial combines Magnolia's component autogeneration function and multilanguage capabilities.

The tutorial takes you through the process of creating a new page template that:

Autogeneration is useful for pages that require standard content. It eliminates the need for editors to create the same content over and over again. It is also a way to standardize content because you can restrict editorial access to components and component actions.

The tutorial assumes that there are two languages configured in the site definition (EE) or server configuration (CE), and that you are using a single tree multilanguage page structure.

You can download the configurations and import them if you prefer not to configure from scratch.

Creating the template definition

To create the template definition;

  1. In Templating Kit > Templates /pages create a new content node /stkAutogenerated and add two properties.
    1. extends set to /modules/standard-templating-kit/templates/pages/stkArticle. This means that the template will use the configuration of the Article template except changes configured in the new definition.
    2. title set to Autogenerated Multilingual. This is the title that shows up in the Template column in the Pages app.
  2. In the new template add an /areas/main/areas/content/autoGeneration/content node structure. The autoGeneration/content part identifies the configuration as autogenerated components.
    1. Add one property generatorClass and set it to info.magnolia.rendering.generator.CopyGenerator. CopyGenerator creates nodes and properties identical to those found in a configuration linked to in the templateId property.
  3. Under autoGeneration/content add a content node for each component with the properties detailed below. All components require a nodeType and templateId property. The rest of the properties are component-specific.
    1. componentOne is a Text and Image component. Here we define only the subtitle. You can add text, image and imageLocation properties if you like.
      1. nodeType set to mgnl:component. This node type is used for all components.
      2. templateId set to standard-templating-kit:components/content/stkTextImage. This is the path to the component definition.
      3. subtitle and subtitle_de set to the text to render in English and German.
    1. componentTwo is a Quoted Text component. The component allows for an author and rich text content.
      1. nodeType set to mgnl:component
      2. templateId set to standard-templating-kit:components/content/stkQuotedText. This is the path to the component definition.
      3. author and author_de set to the text to render in English and German.
      4. text and text_de set to the HTML to render in English and German.
Node nameValue

   pages

 

 stkArticle

 

 stkAutogenerated

 

 areas

 

 main

 

 areas

 

 content

 

 autoGeneration

 

 content

 

 firstComponent

 

 nodeType

mgnl:component

 subtitle

Autogenerated text image

 subtitle_de

Vorgenerierter Titel auf deutsch

 templateId

standard-templating-kit:components/content/stkTextImage

 secondComponent

 

 author

Aristotle

 author_de

Albert Einstein

 nodeType

mgnl:component 

 templateId

standard-templating-kit:components/content/stkQuotedText 

 text

 <p>Education is the best provision for the journey to old age.</p>

 text_de

 <p>Das Schönste, was wir entdecken können, ist das Geheimnisvolle.</p>

 generatorClass

info.magnolia.rendering.generator.CopyGenerator

 extends

/modules/standard-templating-kit/templates/pages/stkArticle

 title

 Autogenerated Multilingual

See Template definitions for more.

Making the template available

To make the template available in the Pages app.

  1. In Templating Kit > Site Definitions /default/templates/availability/templates create a new node /stkAutogenerated.
  2. Add an id property and set it to standard-templating-kit:pages/stkAutogenerated. This is the path to the template definition.
Node nameValue

 default

 

 templates

 

 prototype

 

 availability

 

 templates

 

 stkHome

 

 stkSection

 

 stkArticle

 

 stkAutogenerated

 

 id

standard-templating-kit:pages/stkAutogenerated 

 ....

 

See Template availability for more.

Creating a page

Create a new page in the Pages app and assign the Autogenerated Multilingual template to it. The template is available at the same level in the page hierarchy as the Article template. See Categories and subcategories for more.

Here's the new page with the autogenerated content in English and German.

 

  • No labels