The 5.7 branch of Magnolia reached End-of-Life on December 31, 2023, as specified in our End-of-life policy. This means the 5.7 branch is no longer maintained or supported. Please upgrade to the latest Magnolia release. By upgrading, you will get the latest release of Magnolia featuring significant improvements to the author and developer experience. For a successful upgrade, please consult our Magnolia 6.2 documentation. If you need help, please contact info@magnolia-cms.com.

Content dependencies are references between content items. When a page links to another page, a dependency is created. Similarly, when a page uses an asset from the DAM, a dependency is created between the page and the asset.

The Content Dependencies module displays dependencies between the selected content item and other items, whether the items reside in the same Magnolia workspace or in different ones. Editors can see the consequence of deleting the selected item and whether dependent items need to be activated together.

Installing

Maven is the easiest way to install the module. Add the following to your bundle. The parent POM of your webapp project should set the latest version of the module automatically. Should you need to use a specific module version, you can define it using the <version/> in the dependency.

<dependency>
  <groupId>info.magnolia</groupId>
  <artifactId>magnolia-module-content-dependencies</artifactId>
</dependency>

Dependencies tab

The module includes a preconfigured Dependencies tab that is designed to be added to a page properties dialog. The tab has two fields:

  1. Lists content items that link to the item
  2. Lists items the item links to. 

The Dependencies tab is configured in /modules/dependencies/dialogs/tabDependencies. Both fields extend the reference field configuration.

Node name

Value

 
dependencies


 
dialogs


 
reference


 
class

info.magnolia.module.dependencies.field.DependenciesFieldDefinition

 
referencesTo

false 

 
tabDependencies


 
fields


 
referencesTo


 
references


 
pages


 
appMapping

app:pages:browser

 
workspace

website

 
referenceProperties


 
link


 
extends

/modules/dependencies/dialogs/reference

 
referencesTo

true

 
referencesFrom


 
references


 
pages


 
appMapping

app:pages:browser

 
workspace

website

 
referenceProperties


 
image


 
assets


 
pathResolver


 
class

info.magnolia.module.dependencies.field.resolver.AssetPathResolverImpl

 
appLocationFactory


 
class

info.magnolia.module.dependencies.field.factory.DamAppLocationFactoryImpl 

 
appMapping

app:assets:browser

 
workspace

dam

 
extends

/modules/dependencies/dialogs/reference

Properties:

tabDependencies

required

Dependencies tab.

fields

required

Fields node.

<field name>

required

referencesFrom and referencesTo fields extend the generic references field.

references

required

References node.

<workspace name>

required

Arbitrary node name. One for each workspace you want to track.

appMapping

required

Subapp in app:<app name>:<subapp name> format.

workspace

required

Workspace name.

nodeType

required

Node type.

referenceProperties

required

See Reference properties.

pathResolver

optional

Path resolver node.

class

optional, default is info.magnolia.module.dependencies.field.resolver.PathResolverImpl

Default implementation returns a node's path. info.magnolia.module.dependencies.field.resolver.AssetPathResolverImpl implements PathResolver for assets.

appLocationFactory

optional

App location factory node.

class

optional, default is info.magnolia.module.dependencies.field.factory.AppLocationFactoryImpl

Default implementation creates an app's location. info.magnolia.module.dependencies.field.factory.DamAppLocationFactoryImpl implements AppLocationFactory for the Assets app.

label

optional

Label displayed in dialog.

class

required

info.magnolia.module.dependencies.field.DependenciesFieldDefinition shows dependencies to and from workspaces.

referencesTo

optional, default is false

Whether items linking to the item should be included.

Adding Dependencies tab to dialogs

The easiest way to make the Dependencies tab available to editors is to use the ready-made tab from the module. 

  • JCR: If you configure your dialog using JCR nodes, extend the tabDependencies definition. 
  • YAML: If you configure your dialog using a YAML file, paste the tab configuration below into your form definition.

Example: Adding Dependencies tab to MTE's pageProperties dialog.

mte/dialogs/pages/pageProperties.yaml
form:
  i18nBasename: info.magnolia.templating.models.messages
  label: pages.pageProperties.label
  tabs:
    - name: tabMain
      # Main tab configuration
    - name: tabMeta
      # Meta tab configuration
    - name: tabDependencies 
      fields:
        - name: referencesTo
          fieldType: dependencies
          referencesTo: true
          references:
            pages:
              appMapping: app:pages:browser
              workspace: website
              referenceProperties:
                - link
        - name: referencesFrom
          fieldType: dependencies
          referencesTo: false
          references:
            pages:
              appMapping: app:pages:browser
              workspace: website
              referenceProperties:
                document: document
                download: download
                image: image
actions:
# Actions configuration

Here is the Dependencies tab after adding it to the Travel demo's Page properties dialog and viewing it on the About page.

  • This page is depended upon by
    • Pages: Lists pages that link to the page.
  • This page depends on:
    • Pages: Lists pages the page links to.
    • Assets: Lists assets added to the page.

All links are clickable and open the item in the target app.

Here are the components on the About page that are picked up in the depends on section of the dialog.

Reference properties

Reference properties are properties that the module uses retrieve nodes that an item depends on. They are typically properties that hold references to other nodes and whose value is the JCR identifier or UUID. 

If you do not include the correct reference properties in your configuration, the items will not show up in the depends on section of the Dependencies tab.

The easiest way to find the correct reference properties to configure is to look in the JCR Browser app.

Here is the video component (column 1) and Our Company teaser component (column 2) on the About page in the website workspace in the JCR browser.

Deletion Warnings

The module displays dependency-ware deletion warning messages in the Pages and Assets apps by default. The confirmation dialog lists links to the referring items that will be broken once the deletion is complete.

 

Deletion warnings are configured in the  confirmDeleteAsset action defintion. The configuration patterns follows that of the Dependencies tab (above). 

You can configure dependency-aware delete warnings in any app by adding a references node to the delete confirmation action. 

Example: confirmDeleteAsset action in the Assets app configured in /modules/dam-app/apps/subapps/browser/actions/confirmDeleteAsset.

 subApps:
  browser:
    subAppClass: info.magnolia.ui.contentapp.browser.BrowserSubApp
    class: info.magnolia.ui.contentapp.browser.BrowserSubAppDescriptor
    actions:
      confirmDeleteAsset:
        icon: icon-delete
        successActionName: delete
        class: info.magnolia.module.dependencies.action.DependencyAwareConfirmationActionDefinition
        availability:
          multiple: true
          writePermissionRequired: true
          rules:
            - name: IsNotDeletedRule
              implementationClass: info.magnolia.ui.framework.availability.IsNotDeletedRule
        references:
          - name: website
            nodeType: mgnl:page
            workspace: website
Node nameValue

 
subApps


 
browser


 
actions


 
confirmDeleteAsset


 
availability


 
references


 
website


 
nodeType

mgnl:page

 
workspace

website

 
class

info.magnolia.module.dependencies.action.DependencyAwareConfirmationActionDefinition

 
icon

icon-delete

 
successActionName

delete

Properties:

<action name>

required

Action node.

references

required

References node.

<workspace name>

required

Arbitrary node name. One for each workspace you want to track.

workspace

required

Workspace name.

nodeType

required

Node type.

class

required

info.magnolia.module.dependencies.ui.action.DependencyAwareConfirmationActionDefinition adds dependency awareness to the action.

icon

optional

CSS class that identifies an icon font used on the action. See Icons.

successActionName

required

Name of action to execute on confirmation.