TerranRich
TerranRich

Reputation: 1298

How do I store content in Drupal 9 about wrestlers and their entrance themes in such a way that a theme entry can be "borrowed" from another wrestler?

I am building a site in Drupal 9 that will, ideally, list the entrance themes of professional wrestlers. I am having trouble figuring out the architecture of such a site given the following requirements:

Here is a real-world example:

My initial plan was to store Wrestler/Team and Theme Track as content types. Since themes can be re-used, it makes sense to store them as their own reference-able entities. Each Wrestler/Team then has a field called Themes List, which points to a Theme Usage paragraph type. Each Theme Usage ¶ stores: the first date on which this theme was used, notes about its usage, and a reference to the Theme Track content node itself.

However, this soon turned out to be problematic, because you cannot reference specific instances of another node's paragraphs. Meaning, borrowed theme listings wouldn't be possible.

My next idea was to add a Theme Usage custom block type (or content type, but I chose custom block for administrative reasons), so that each individual usage (not only theme tracks) could be an entity that could be referenced. Under this model, each of a wrestler's theme listing entries would point to a Theme Usage custom block. Each Theme Usage has one field that points to the Theme Track (content type) and another that points to other Theme Usage blocks (for borrowed themes).

However, using this method, I'm not sure how to grab information on each borrowed Theme Usage's corresponding Wrestler/Team node using this model. Using paragraphs before, each theme usage was linked intrinsically to the Wrestler/Team node referencing it. But using this second method, there is no similar "ownership" in this manner, meaning that each Theme Usage is a rogue entity that is referenced by a Wrestler/Team node, rather than being linked to a Wrestler/team node.

I'm at an impasse here, unsure of how to implement this architecture in Drupal. I know it can be done, but I'm just not seeing it at the moment.

tl;dr: How do I store content in such a way that each wrestler has their own listing of entrance themes, and that any theme entry can reference any one of another wrestler's individual themes? This reference must reveal information about not only the theme, but the wrestler from which the theme is being "borrowed" as well.

Upvotes: 0

Views: 51

Answers (1)

Kien Nguyen
Kien Nguyen

Reputation: 2691

You are close to achieving it with the first idea. Remember that Drupal references are actually relationships between tables in the database. So you always have the ways to get the referencing entity from the referenced entity using view filter (through admin UI) or database query (programmatically)

I will summarize the solution below:

enter image description here

  • Wrestler/Team and Theme Track are content types
  • Wrestler/Team content type has a field called Themes List which reference to Theme Usage paragraph type
  • Theme Usage has a field called Theme Track which reference to Theme Track content type (and other metadata fields)
  • Theme Track content type has a field called Borrowed Theme List which reference to Theme Borrowing paragraph type
  • Theme Borrowing has a field called Theme Track which reference to Theme Track content type (and other metadata fields)

Upvotes: 0

Related Questions