Skip to main content

Content References

Automatically generated reference resolvers#

When working with link-fields, reference resolvers are automatically created in the mgnl-config/restEndpoints/delivery folder in our project.

If we create TitleImage component and add some link-field properties to the yaml file as shown in the example below,

TitleImage.yaml
label: TitleImageform:  properties:    - name: title      label: Title      $type: textField      i18n: true
    - name: image      label: Image      $type: damLinkField
    - name: link      $type: linkField      datasource:        $type: jcrDatasource        workspace: tours

we get the following references in mgnl-config/restEndpoints/delivery/pages_v1.yaml file.

pages_v1.yaml
references:  - name: imageReference    propertyName: image    referenceResolver:      class: info.magnolia.rest.reference.dam.AssetReferenceResolverDefinition      assetRenditions:        - large        - medium        - small  - name: linkReference    propertyName: link    referenceResolver:      class: info.magnolia.rest.reference.jcr.JcrReferenceResolverDefinition      targetWorkspace: tours


Override the auto-generated reference resolvers#

We can override some of the references in the TitleImage.yaml file by adding a reference resolver directly to the property we want to resolve.

TitleImage.yaml
label: TitleImageform:  properties:    - name: title      label: Title      $type: textField      i18n: true
    - name: image      label: Image      $type: damLinkField      referenceResolver:        class: info.magnolia.rest.reference.dam.CustomReferenceResolverDefinition        assetRenditions:          - large          - small
    - name: link      $type: linkField      datasource:        $type: jcrDatasource        workspace: tours

Prevent automatic generation of reference resolvers#

To prevent automatic generation of references, set the magnolia property generateReferences to false in the package.json file. The default value of this property is true.

The effect will be visible after reloading the configuration by pressing the r keyword or restarting the HA CLI.

In this case, the reference resolvers must be defined in the mgnl-config folder. Note that if automatic generation of references is disabled, reference resolvers cannot be overridden for specific properties.


info

For more information about reference resolving, please refer to the Resolving references with the delivery endpoint section of the Magnolia documentation.