Content Dependencies module

Content management Bundled: DX Core

Edition DX Core

License

MLA

Issues

Maven site

Latest

3.0.0

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 enables you to display and manage these relationships, whether the items reside in the same Magnolia workspace or in different ones.

With this module, you can configure:

  • A Dependencies tab in a content app to list where an item links to and where it is linked from. This is useful to identify related content that needs to be published together.

  • A warning dialog that appears when content with dependencies is marked for deletion. This warns editors about the risk of breaking links before they confirm the deletion.

  • A View links action that opens a dialog showing where the selected item is referenced. This is enabled by default in the Pages and Assets apps, and you can configure it for other content apps if needed.

Content dependency limitations

Content dependencies, including those shown in the View links dialog and deletion confirmation dialogs, rely on reference data stored in the JCR. Once an item is marked for deletion, its references are removed from the repository. As a result, links from or to deleted items are no longer available to dependency checks.

  • If you view links for an asset that belongs to a page already marked for deletion (but not yet permanently deleted), no dependency is shown. If the page is later restored, the link to the asset is lost and may result in a broken reference.

  • When you check links at the folder level, dependencies are counted as distinct links, not aggregated counts of each child’s links. For example, if three assets in a folder all link to the same page, the dialog shows one incoming link (the page), not three.

Deletion warning dialogs are configured by default in the Pages and Assets apps.

By default, dependencies are only checked between pages and assets, not against other content apps. For example, if an editor deletes an asset used in the Tours app, no warning appears. Warnings are only shown when deleting a page or an asset linked to a page.

You can configure this functionality to include additional content apps if needed.

Installing with Maven

Maven is the easiest way to install the module. Add the following to your bundle:

<dependency>
  <groupId>info.magnolia</groupId>
  <artifactId>magnolia-module-content-dependencies</artifactId>
  <version>3.0.0</version> (1)
</dependency>
1 Should you need to specify the module version, do it using <version>.

Add a dependencies tab to a dialog

A typical use case is to add a dependencies tab to a page properties dialog. This is useful if you want to see any related content that needs to be published with the page.

In this example, we add a dependencies tab to MTK’s basic page dialog. The dependencies tab has two fields:

  1. List of content items that link to the item.

  2. List of content items the item links to.

<light-module-folder>/<light-module-name>/decorations/mtk2/dialogs/pages/basic.yaml
form:
  properties:
    referencesTo:
      class: info.magnolia.module.dependencies.ui.field.DependenciesViewDefinition
      referencesTo: true
      references:
        pages:
          appMapping: app:pages-app:browser
          workspace: website
          referenceProperties:
            - link
            - linkTypepage #teaser component
    referencesFrom:
      class: info.magnolia.module.dependencies.ui.field.DependenciesViewDefinition
      referencesTo: false
      references:
        pages:
          appMapping: app:pages-app:browser
          workspace: website
          referenceProperties:
            - link
            - linkTypepage #teaser component
        assets:
          appMapping: app:dam:jcrBrowser
          workspace: dam
          referenceProperties:
            - image
            - thumbnail
          pathResolver:
            class: info.magnolia.module.dependencies.field.resolver.AssetPathResolverImpl
          appLocationFactory:
            class: info.magnolia.module.dependencies.field.factory.DamAppLocationFactoryImpl

  layout:
    tabs:
      - name: tabDependencies
        fields:
          - name: referencesTo
          - name: referencesFrom

Here is the dependencies tab after adding it to the Travel Demo’s Page properties dialog and viewing it on the About page.

  • This content is depended upon by:

    • Pages: Lists pages that link to the page.

  • This content 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.

Dependencies tab in Page properties

Table 1. Dependencies tab properties
Property Description

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

                     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.ui.field.DependenciesViewDefinition shows dependencies to and from workspaces.

             referencesTo

optional, default is false

Whether items linking to the item should be included.

Reference properties

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

If you don’t include the correct reference properties in your configuration, the items don’t show up in the depends on section of the dependencies tab.

If you don’t include any reference properties, the three default values (image, contact, and link) are used.

To find the correct reference properties to configure, export the JCR content or look in the JCR Browser app.

Configure deletion warnings

The module provides dependency-aware deletion warnings in the Pages and Assets (JCR-stored assets only) apps by default. These warnings appear in a confirmation dialog Links column, which lists broken links that would result from the deletion. Each link, displayed in blue, is clickable and opens the Links dialog.

Marking an item for deletion confirmation dialog

Deletion warnings are configured in the confirmDeleteAsset and confirmMarkDeletion action definitions. The configuration patterns follow those outlined in the Dependencies tab section above.

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

confirmMarkDeletion action in the Assets app

magnolia-content-dependencies-ui/src/main/resources/content-dependencies-ui/decorations/dam-assets-app/apps/dam.yaml
      confirmMarkDeletion:
        icon: icon-trash
        $type: contentDependencies:deleteConfirmationAction
        references:
          website:
            nodeType: mgnl:page
            workspace: website
The viewLinks action produces the same result as the Links column in the deletion confirmation dialog, which lists any links referencing the selected item. Therefore, both the node type configuration and the workspace of contentDependencies:deleteConfirmationAction and contentDependencies:viewLinks must be the same
Property Description

<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 used for the action. For available names, see Icons.

     successActionName

required

Name of action to execute on confirmation.

The module also provides a viewLinks action, which opens a dialog listing where the selected item is referenced. This action works the same way as the View links option available by default in the Pages and Assets apps.

View links dialog

You can add it to other content apps as needed.

Example configuration in a custom app:

      viewLinks:
        $type: contentDependencies:viewLinks
        icon: icon-link
        references:
          website:
            nodeType: mgnl:page
            workspace: website
The viewLinks action produces the same result as the Links column in the deletion confirmation dialog, which lists any links referencing the selected item. Therefore, both the node type configuration and the workspace of contentDependencies:deleteConfirmationAction and contentDependencies:viewLinks must be the same
Property Description

<action name>

required

Action node. In this case, viewLinks.

     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.ViewLinksActionDefinition executes the action.

     icon

optional

CSS class that identifies an icon used for the action. For available names, see Icons.

If you add this action to a new app, also include it in the app’s action bar so it is available to users.

Examples

Pages app (default):

      viewLinks:
        $type: contentDependencies:viewLinks
        icon: icon-link
        references:
          website:
            nodeType: mgnl:page
            workspace: website

Assets app (default):

      viewLinks:
        $type: contentDependencies:viewLinks
        icon: icon-link
        references:
          website:
            nodeType: mgnl:page
            workspace: website
Feedback

DX Core

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the DX Core docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules