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

DEVELOPER PREVIEW

Link field definition renders a text field and a browse button that allows you to select an item from a configured app. The link field is used to select targets inside Magnolia (for example, a page to tease or an asset to render an image) where it stores a reference to the selected item.

The link field allows you to choose items from any content app, including non-JCR apps.

Link field definition is part of the Magnolia 6 UI framework. The fully qualified class name is info.magnolia.ui.field.LinkFieldDefinition.

If you work with the Magnolia 5 UI framework, see Link field for Magnolia 5 UI instead.

Example link field definition

linkField:
  $type: linkField
  label: linkField
  buttonSelectNewLabel: Select new ...
  buttonSelectOtherLabel: Select another ...
  preview:
    implementationClass: info.magnolia.contacts.app.ContactPreview
  chooser:
    workbenchChooser:
      appName: contacts-v8

Link field properties

<field name>

Name of the field.

class

required (unless $type is used)

Fully qualified name of the link field definition class.

If the definition class is annotated with info.magnolia.ui.field.FieldType, you can use the $type property instead.

$type

You can use this as a shortcut for class if the definition class is annotated with info.magnolia.ui.field.FieldType. The proper value is defined by the annotation.

Example class annotation
@FieldType("linkField")
public class LinkFieldDefinition<T> extends ConfiguredFieldDefinition<String> implements WithDatasource<DatasourceDefinition> {
...
}
To use the $type property in YAML, see Example link field definition.

chooser

required

Generic chooser for items of any kind. Configured via ChooserDefinition.

workbenchChooser

required

Chooser based on a workbench, usually corresponding to an app that uses the same workbench. Configured via WorkbenchChooserDefinition.

appName

required (unless datasource is used)

Name of the target app used to create the content view to choose the item from. The view is automatically resolved from the app name via AppAwareWorkbenchChooserDefinition.

datasource

Connects the target app to a data source for custom implementation. If both datasource and appName are defined, the datasource property will prevail.

Example custom implementation
chooser:
  workbenchChooser:
    datasource: *someDatasource # here an already defined data source is reused
    columns:
      - name: jcrName
        caption: name
        $type: jcrNameColumn
      - name: value
        caption: value
      - name: jcrPath
        caption: path
        $type: jcrPathColumn

buttonSelectNewLabel

optional, default is Select new ...

Button label before the target node is selected. The value is i18n-able.

buttonSelectOtherLabel

optional, default is Select another ...

Button label after the target node is selected. The value is i18n-able.

editable

optional, default is true

Makes the text box displaying the link editable once a target has been selected.

label

optional

Field label displayed to editors. The value can be literal or a key of a message bundle.

If you do not provide the property, Magnolia will fall back to a generated i18n key.

If you do not want a label at all, define the property and set its value to a blank space such as label: " " in YAML.

placeholder

optional

Placeholder text to be displayed in the empty field. The value is i18n-able.

preview

optional

Renders a preview of the selected content. The preview component typically displays an image thumbnail and some metadata.

implementationClass

required

Any class that implements the ItemPreviewComponent interface. Example:

  • info.magnolia.contacts.app.ContactPreview, which displays a contact thumbnail and information.

See also Common field properties.

  • No labels