Best way to handle 2+ similar collections

I’m wondering what are the best/most common methods for handling a structure like this:

I will have news posts, review posts, and general article posts on my site. I want structured content for the reviews, for example, they will have specific sections for the author add content too. News posts will not have these sections, neither will general articles.

However, I want to limit repeating myself and having multiple collections with similar metadata structures, and risk changing one without changing another. (Things like “title”, “slug”, “tags”, “excerpt” would be shared across all 3 types of posts)

What’s the best way to approach this?

Is there a way to get super advanced with a single collection to adjust what fields are available? Maybe there’s a good way to have a “posts” collection with the metadata, then have separate collections for post content (worried about the UX of this for CMS users)?

1 Answer

1

From a data perspective, I would prefer using relational data.

However, Directus has some limitations with relational data that you should be aware of:

  • Search in Data Studio does not include fields from related collections. Although you can filter on relational fields, the process is rather tedious.
  • Versioning only applies to the collection being edited. It does not extend to related collections (except when updating the foreign key, of course).

The “super-advanced single collection” approach, could most likely be achieved through extensive use of field conditions—essentially hiding fields that aren’t needed based on other values within the same collection.

There are probably additional pros and cons (performance, security, …) to each approach, so I’m curious to hear what others think.

You are right Nik, The single collection approach with the conditions works perfectly with me, not sure what's your concerns for the performance and security I would like to know more about it, but I'm excited about this PR for fixing some issues I may face in this approach https://github.com/directus/directus/pull/25646

About your current use case Floh, I think you need have a look on the agencyos template, it does have the single collection approach for posts with three types (blog, project, video). in case your website not multingilal I would you suggest to use this seo extension as well since it's not added to the agencyos yet. https://www.npmjs.com/package/@directus-labs/seo-plugin