Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Is it possible to use this module to create a related content block via a contextual filter?
I'm using Entity Embed with a content type ("Parent") that can embed several other content types ("Child1", "Child2", "Child3"). When visiting a node of type Child1/2/3, I'd like to display either (1) a link back to the Parent node that has the current node embedded within it, or (2) links to the Child1/2/3 nodes that are also on the same Parent node.
Hope this makes sense! Any guidance is appreciated.
Comments
Comment #2
marcoscanoHave you tried using the
::listUsage()
method of the service this module provides?To achieve the first scenario I believe something similar to the following code should do the trick:
For the second scenario, this module does not provide an API function to retrieve that info directly, but the structure of the information in the database is not complex, you should be able to perform a custom query on
{entity_usage}
and fetch all "siblings" of the node you are viewing.Comment #3
marcoscanoClosing for now, feel free to re-open if you need further information.
Comment #5
graham73may CreditAttribution: graham73may at Soapbox Communications Ltd commentedI needed similar functionality to what is being discussed here.
Some of my sources were Paragraphs so I needed to use listSources() which returned the source_type.