static-cms icon indicating copy to clipboard operation
static-cms copied to clipboard

Feature request: query referenced entries for use troughout the app, not just by relation widget.

Open Skrubbadubba opened this issue 1 year ago • 0 comments

Explanation

Say for a certain collection you have a relation field. There should be the option to filter, sort and group the entries by any of the fields that are in the entry referenced by the relation widget, not just the single value_field returned by the relation widget.

Justification

The relation widget together with shumiyao's custom Uuid widget (should be officially merged IMO, it's really nice) makes it straight forward to structure content like relational data. If you have the slug for each entry be the uuid, and you use the uuid field as the value_field for relation widgets, the rest of your project can fetch referenced entries by using for example dynamic imports. The same approach can be used in custom CMS components.

However, if you use this approach, there will most likely come up situations where you would want to also use referenced entries (like you do in the rest of your project), for configuring the CMS. What I am referring to is every configuration option that takes in the name of a field (sortable_fields, view_filters, view_groups, filter, summary, etc)

Example use case

Say you have a "posts" collection. One of the fields for post entries is "author". That author field is a relation widget with a value of the slug of an entry inside an "authors" collection. Each author entry contains not only their name but perhaps their age, city, role within the organisation, stuff like that. On your website, you have a "PostCard" component that shows the post's title and excerpt from the post entry. It also imports the author entry referenced in the post entry, and shows both the author's name and role. In the CMS UI, it might make sense to sort or group the posts collection by the authors' roles.

Skrubbadubba avatar Mar 07 '23 16:03 Skrubbadubba