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

Dialogs are used for content entry. A dialog defines the editable content properties of a template. Pages, area and component templates can all use dialogs.A dialog is basically an HTML form with input fields for each content property. Editors type content into the fields and the dialog saves it in the repository.

The functionality of each field in a dialog is provided by a field definition class that allows the editor to perform a task such as enter text, upload an image, select a date etc. Fields are assembled into tabs and tabs into dialogs.

All dialogs used throughout the system are configured in the same way. For example, the configuration of dialogs used in apps and components is the same.

Dialog properties

A dialog definition contains actions and a form.  It is a very simple definition. The actual work is done in the form and action definitions that determine what content users can enter into the dialog and how to submit it:

  • Action definitions control what happens when a user clicks a dialog button. Typical dialogs have save and cancel actions. Each action definition displays as a button in the dialog.
  • The form definition defines the tabs and fields in the dialog.

Simple dialog definition:

<module name>/dialogs/<dialog name>.yaml
form:
  tabs:
    - name: tabText
      label: Text
      fields:
        - name: title
          class: info.magnolia.ui.form.field.definition.TextFieldDefinition
          label: Title
actions:
  commit:
    class: info.magnolia.ui.admincentral.dialog.action.SaveDialogActionDefinition
    label: Save
  cancel:
    class: info.magnolia.ui.admincentral.dialog.action.CancelDialogActionDefinition
    label: Cancel
Node nameValue

 modules

 

 <module name>

 

 dialogs

 

 <dialog name>

 

 form

 

 tabs

 

 tabText

 

 fields

 

 title

 

 class

info.magnolia.ui.form.field.definition.TextFieldDefinition

 label

Title

 label

Text

 actions

 

 commit

 

 class

info.magnolia.ui.admincentral.dialog.action.SaveDialogActionDefinition

 label

save

 cancel

 

 class

info.magnolia.ui.admincentral.dialog.action.CancelDialogActionDefinition

 label

close

Nodes:

<dialog-name>

required

Arbitrary node name. Typically matches the template it edits. For example the component definition node and dialog definition node for a link component could both be named link. This is not required and one dialog can be used for more than one template.

form

required

Contains a form definition which defines the fields where content is entered.

actions

required

Contains  action definitions  which define how the data is submitted. The actions are rendered to users as buttons. Typically you need at least Save and Cancel actions.

modalityLevel

optional

Modality level defines how intrusive the dialog is. Valid values are strong (default), light and non-modal.

actionArea

optional

Allows you to configure secondary actions.

wide

optional, default is false

true opens the dialog in wide mode using all available horizontal space.

Click the expand/collapse button in the top right corner to toggle between the wide and normal (720px) modes.

Location of dialog definitions

 YAML file pathJCR node path in config workspace
Dialog definition$magnolia.resources.dir/<module-name>/dialogs/modules/<module-name>/dialogs

Referencing dialogs

Templates reference dialog definitions in their template definition. This is how the system knows which dialog to associate with the template. Page, area and component templates reference dialogs in the same way by using the dialog property.

Example: A component definition that references a textImage dialog.

<module name>/templates/components/textImage.yaml
dialog: my-module:components/textImage
renderType: freemarker
templateScript: /components/textImage.ftl
title: Text &amp; Image Component
Node nameValue

 my-module

 

 templates

 

 components

 

 textImage

 

 dialog

my-module:components/textImage

 renderType

freemarker

 templateScript

/components/textImage.ftl

 title

Text & Image Component

Property:

dialog

optional

Dialog definition ID in <module-name>:<path to dialog definition> format.

The ID has two parts, separated by a colon:

  1. <module-name> : The name of the module which contains the dialog definition.
  2. <path>: Relative path to the dialog definition inside dialogs root item. For example the dialog ID my-module:components/textImage either points to the YAML file $magnolia.resources.dir/my-module/dialogs/components/textImage.yaml or to the JCR node /modules/my-module/dialogs/components/textImage in the configuration workspace.

Using dialogs in templates

Dialogs are most commonly used for content entry in components. This is where the bulk on content is entered. But dialogs are also useful for page and area templates. Here are a few suggestions:

  • Page dialogs:
    • Content entry: Use the dialog for content entry that is not necessarily rendered on the page. For example, to enter a meta title and description that is injected into the <head> element, or a page excerpt for use in teaser components on other pages.
    • Navigation: Set up a field to mark the page for inclusion in or exclusion from navigation. You could also define browser header and tab titles.
    • Information: Page dialogs can provide editors with useful information. For example, the Content Dependencies module includes a generic tab that collects page dependencies such as other pages and assets. This information is useful when deleting a page.
  • Area dialogs: While most areas contain components, dialog content can be rendered by the script in noComponent areas.

Configuring secondary actions

The actionArea node lets you provide additional actions and specify a renderer, if required. You need a renderer when the action requires more than just a button (for instance for an upload action).

The choose dialog in the Assets app is an example.The dialog allows editors to upload assets to the DAM while working in other apps.

The configuration is in  /modules/dam-app/apps/assets/chooseDialog:

Node name 

 chooseDialog

 

  actions

 

  commit

 

  cancel

 

  upload

 

  uploadAndEdit

 

 actionArea

 

 secondaryActions

 

  upload

 

  uploadAndEdit

 

 actionRenderers

 

  upload

 

 rendererClass

info.magnolia.dam.app.assets.field.UploadAssetActionRenderer

  uploadAndEdit

 

  rendererClass

info.magnolia.dam.app.assets.field.UploadAndEditActionRenderer
actionArea

optional

Contains the action area configuration

secondaryActions

required

Add subnodes to match the secondary actions defined in the actionsnode. The order of the subnodes defines the sequence in which they are rendered. Actions configured under secondaryActions are rendered on the left  and other actions are on the right side.

<actionName>

required

Secondary action name.

actionRenderers

optional

Define a subnode for each action which requires its own renderer.

rendererClass

required

The class of the specific renderer which must implement  ActionRenderer .

Reusing configuration

Magnolia provides mechanisms to reuse dialogs or more general said to reuse configuration items. See Reusing configuration and Generic tab for a dialog