Content Dependencies module
Content management Bundled: DX Core
Edition | DX Core |
---|---|
License |
|
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:
-
List of content items that link to the item.
-
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.
Property | Description |
---|---|
|
required Dependencies tab. |
|
required Fields node. |
|
required
|
|
required References node. |
|
required Arbitrary node name. One for each workspace you want to track. |
|
required Subapp in |
|
required Workspace name. |
|
required Node type. |
|
required See Reference properties. |
|
optional Path resolver node. |
|
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 |
|
optional App location factory node. |
|
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 |
|
optional Label displayed in dialog. |
|
required info.magnolia.module.dependencies.ui.field.DependenciesViewDefinition shows dependencies to and from workspaces. |
|
optional, default is 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.
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
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 |
---|---|
|
required Action node. |
|
required References node. |
|
required Arbitrary node name. One for each workspace you want to track. |
|
required Workspace name. |
|
required Node type. |
|
required info.magnolia.module.dependencies.ui.action.DependencyAwareConfirmationActionDefinition adds dependency awareness to the action. |
|
optional CSS class that identifies an icon used for the action. For available names, see Icons. |
|
required Name of action to execute on confirmation. |
Add the viewLinks
action to an app
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.
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 |
---|---|
|
required Action node. In this case, |
|
required References node. |
|
required Arbitrary node name. One for each workspace you want to track. |
|
required Workspace name. |
|
required Node type. |
|
required info.magnolia.module.dependencies.ui.action.ViewLinksActionDefinition executes the action. |
|
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. |