Installation and basic usage

Last updated on
20 February 2023

Installation & Usage

A relationship between two entities is considered so when a source entity points to a target entity through one of the methods supported by the module, which currently are:

  • Entities related through entity_reference fields
  • Entities related through link fields
  • Entities embedded into text fields using the Entity Embed module
  • Entities embedded into text fields using the LinkIt module
  • Standard HTML links inside text fields (when pointing to an entity URL).
  • Entities related through block_field fields (provided by the Block Field module)

You can configure which entity types should be tracked as source, and which ones should be tracked as target. By default all content entities (except files and users) are tracked.

In order to modify these default settings, navigate to Configuration -> Content Authoring -> Entity Usage Settings (or go to the URL: /admin/config/entity-usage/settings

You can also configure what plugins (from the tracking methods indicated above) should be active. By default all plugins are active.

When a source entity is created / updated / deleted, all active plugins are called to register potential relationships that may exist to any target entity.

Accessing the usage statistics

Content entities can have a local task link (Tab) on its canonical page linking to a "Usage" information page, where users can see where that entity is being used. You can also configure which entity types should have a local task displaying usage information.

Note that only users with permission to 'access entity usage statistics' will see the Usage tab and have access to the page with usage information.

You can also display usage information in Views, or retrieve them in custom code. More information about this is provided below.

The "HTML Links" plugin provided by the module will track links inside WYSIWYG text areas that point to internal entity URLs. By default this works only with relative URLs. If you want to allow users to create links with absolute URLs as well, you need to whitelist your site's domain in the settings page:

Views integration

A basic views integration is provided. To use the tracked information in a view, follow the following steps:

  1. Create a view that has as base table any content entity (Node, User, Etc)
  2. Add a relationship to your view named
    "Information about the usage of this @entity_type"
  3. After adding the relationship, add the field to your view:
    "Usage count"
  4. You will probably want to enable aggregation, to avoid duplicate rows and have the real count sum. To do that, go to the "Advanced" section of the view configuration, select "Use aggregation" to "Yes"
  5. Go to the "Usage count" field you added before, open up the "Aggregation settings" form, and select "SUM"

In your view (or anywhere else) you can build a link to the usage page of your entity by using the following structure:
/{entity_type}/{entity_id}/edit/usage

Make sure the visitors of this page have the permission to 'access entity usage statistics' enabled.

Help improve this page

Page status: No known problems

You can: