Keeping track in which field the reference is made

Created on 30 April 2025, 3 months ago

Hello. Nice work on this module, thanks!

It covers almost all use-cases I have, besides 1: the users on my project are interested in which field an entity is being referenced. As far as I can see, this isn't being tracked currently.

Do you see this feasible within the current module's architecture or is this something the module will never support?

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium rp7

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @rp7
  • 🇷🇴Romania claudiu.cristea Arad 🇷🇴

    The goal was to keep the table as compact as possible and I didn't see any reason to store also the fields. Probably, if we do, we should store also in the JSON field but is that worth it? Right now I don't see a use case

  • 🇧🇪Belgium rp7

    Just putting my use-case out here: we have a few big content types with a lot of fields and nested paragraph structures. Content comes and goes (unpublish) quite frequently. Before our users unpublish content, they want/need to verify if it's not actively being used (referenced) anywhere. It makes life a lot easier for them to immediately see from which field the other entity is referencing. It's more or less a "killer" feature for them.

  • 🇷🇴Romania claudiu.cristea Arad 🇷🇴

    Thinking more... with the current architecture is not possible because an entity might refer the same target via 2 different fields:

    node(nid456) -> field_term -> taxonomy_term(tid123)
    node(nid456) -> field_other_term -> taxonomy_term(tid123)

    But currently, we only store once the relation between node(nid456) and taxonomy_term(tid123). We don't care which was the field, we're only interested if the relation exists. But did you try https://www.drupal.org/project/entity_usage , that stores also the fields

  • 🇷🇴Romania claudiu.cristea Arad 🇷🇴

    We can add a hook somewhere, so a third party might do whatever they want, including storing more info somewhere

  • 🇷🇴Romania claudiu.cristea Arad 🇷🇴

    No input here. Should we close this?

  • Status changed to Postponed: needs info 26 days ago
  • 🇧🇪Belgium rp7

    Sorry for going AWOL. This completely fell of my radar.

    We can add a hook somewhere, so a third party might do whatever they want, including storing more info somewhere

    That sounds like an option. Where do you think this hook should invoked? My first thoughts tell me TrackPluginBase::getTargetEntities().

    And with "somewhere" I guess you don't mean in the track_usage table. (but I guess - with custom code - I could add an extra colum in there).

  • 🇷🇴Romania claudiu.cristea Arad 🇷🇴

    Maybe we can still add it in the JSON field. Right now w path element looks like

    node:28238:76623

    We probably can make it look like:

    node:28238:76623:field_ref

    But we need a MR. And the upgrade path could be problematic

Production build 0.71.5 2024