3

I'm not sure where Display Template option is supposed to show up on M2M relationships.

Here on movies collection setting up genres:

Relation

and the options

enter image description here

Docs seems confusing about the distinction between Visible Columns and Display Template:

Visible Columns sets the columns the interface shows (we're using name)

Display Template sets the columns the interface shows (we're using {{movie.name}})

Visible Columns does the above; in this example shows the title column in edit page for genres:

enter image description here

Alright, great!

But what about the template? maybe in the collection list?

no, just the count:

enter image description here

I've tried all these templates but nothing shows up anywhere:

  • {{title}}
  • {{movie.title}}
  • {{genre.title}}
  • {{genres.genre.title}}

What is the correct template here? Where is Display Template supposed to show up?

My collections setup:

movies
 title text,
 genres M2M (alias)

genres
 title text

movies_genres
 id pk,
 genre numeric,
 movie numeric

Thanks

Mostafa Bahri
  • 2,303
  • 2
  • 19
  • 26

1 Answers1

2

This applies to O2M Interfaces:

Since there can be more than one related item linked, in the items list, the display template is rendered as a number of items until you interact with the item...

If you place your mouse over the Genres Fields, you should see the display template rendered.

A popover should show up and display the list of items as you defined.

  • Correct. But as you said it only applies to o2m not m2m. I would've expected the same popover behavior for m2m, but that's not the case. – Mostafa Bahri Apr 22 '20 at 12:14
  • I should have been more clear... O2M interfaces include Many to Many and One to Many. They cannot be displayed as a list within the table list layout, so they are displayed as a popover. – Philleep Florence Apr 23 '20 at 18:32
  • I see. But it actually doesn't work as you describe for m2m, while does for o2m. Check this out: Go to [demo app -> news collection](https://demo.directus.io/admin) and add a few related news and see if any popover shows up. – Mostafa Bahri Apr 24 '20 at 15:11