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

LinkFieldDefinition  renders a text field and a browse button that allow the user to select a node from the configured workspace. The link field is used to select targets inside Magnolia, for example a page to tease. Depending on what you want do with the selected node, the system can create a link to it or display its content on the page.

Class: info.magnolia.ui.form.field.definition.LinkFieldDefinition

(warning) The link field replaces the link and uuidLink controls used in Magnolia 4.5.

In addition to defining the targetWorkspace to browse, you need to define a target appName. The target app is responsible for providing a view that is suitable for selecting the target node type. When the target app is a content app, the workbench in the browser subapp is a suitable view and it is used by default. For example, the Contacts app provides a workbench for browsing contacts (mgnl:contact). 

Here is an example link field definition in the stkTeaserContact component. It is used to select a contact to tease.

Node nameValue

 contact


 identifierToPathConverter


 class

info.magnolia.ui.form.field.converter.BaseIdentifierToPathConverter

 contentPreviewDefinition


 contentPreviewClass

info.magnolia.contacts.app.field.component.ContactPreviewComponent

 appName

contacts

 class

info.magnolia.ui.form.field.definition.LinkFieldDefinition

 description

dialogs.paragraphs.teasers.stkTeaserContact.tabTeaser.contact.description

 label

dialogs.paragraphs.teasers.stkTeaserContact.tabTeaser.contact.label

 required

true

 targetWorkspace

contacts

 type

String

You can use all common field properties and the following.

PropertyDescriptionDefault value
appName

Target app name used to create the content view, for example pages. Mandatory. Examples:

appNametargetWorkspace
pageswebsite
assetsdam
contactscontacts
categoriescategories

All content apps provide a workbench. The workbench view is used as the link target chooser by default. However, you can also provide a choose dialog and provide custom actions. See an example in /modules/dam/apps/assets/chooseDialog.


identifierToPathConverter
The link field returns the path of the selected node by default. You can convert the path to a UUID with a converter. Optional.

class

Any class that implements the IdentifierToPathConverter interface. Examples:

  • info.magnolia.ui.form.field.converter.BaseIdentifierToPathConverter

  • info.magnolia.dam.app.assets.field.translator.AssetCompositeIdKeyTranslator converts an asset composite ID key to a path.


contentPreviewDefinition

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


contentPreviewClass

Any class that implements the ContentPreviewComponent interface. Examples:

  • info.magnolia.contacts.app.field.component.ContactPreviewComponent displays a contact thumbnail and information.

  • info.magnolia.dam.app.ui.field.DamFilePreviewComponent. Displays an asset thumbnail and related information.


fieldEditable

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

true

buttonSelectNewLabel

Button label before the target node is selected. Default is "Select new...", retrieved from a message bundle. Optional.

field.link.select.new

buttonSelectOtherLabel

Button label after the target node is selected. Default is "Select another...", retrieved from a message bundle. Optional.

field.link.select.another

targetWorkspace

Name of the workspace in which the target content is stored. Mandatory.

website

targetTreeRootPath

Path where to start browsing the workspace.

/

  • No labels