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

Compare with Current View Page History

« Previous Version 5 Next »

adapted from https://documentation.magnolia-cms.com/display/DOCS56/Developing+and+rendering+custom+content+blocks

Create the module structure we will need:

cd my-light-modules
mkdir -p block-examples/blocks
mkdir -p block-examples/templates/blocks
mkdir block-examples/i18n

Add the block definition:

block-examples/blocks/quote.yaml
class: info.magnolia.editor.block.stock.FieldSetBlockDefinition
templateId: block-examples:blocks/quote
fields:
  quotation:
    class: info.magnolia.ui.form.field.definition.TextFieldDefinition
    rows: 3
  citedPerson:
    class: info.magnolia.ui.form.field.definition.TextFieldDefinition

Add the template definition:

block-examples/templates/blocks/quote.yaml
templateScript: /block-examples/templates/blocks/quote.ftl
renderType: freemarker

Add the template script:

block-examples/templates/blocks/quote.ftl
[#if content.quotation?has_content]
<blockquote>
<p>${cmsfn.decode(content).quotation}</p>
    [#if content.citedPerson?has_content]<cite>${content.citedPerson}</cite>[/#if]
</blockquote>
[/#if]



YZ



  • No labels