Relation widget - multiple collections

Hello, I’d like to reference a post in a collection using the relation widget, but the post could be in any one of three collections

I’m assuming this isn’t possible using the relation widget as it is now so…

  • Are there any solutions for this that people are using?
  • If not, is the easiest way to do this to just include three individual relation widgets?

Otherwise I’d be happy to spend some time on a custom widget to contribute to the community but… that ain’t happening in the next month or two!

1 Like

Yeah, probably three widgets, although that sounds like a pretty rough UX. Can you explain the problem you’re solving at a higher level?

1 Like

Thanks for the response @erquhart!

What I’m trying to do is pretty simple - there will be a sticky post on the landing page which could come from any of three collections - let’s say blogs/reports/commentary

The problem now is that I’m about to be told that there will be more than three collections from which the sticky post will be drawn - so I might have to figure out something a bit more scalable. I can live with the rough UX for three collections, but not more, I think!

Ultimately, the ideal would be to have a relation widget which searches across ALL collections - is this even possible, do you think?

@rub1e A relation widget that could pull from multiple collections would be amazing. Please post back here if you end up making one eventually!

Searching multiple collections in a relation widget would be a cool feature. There are a few other feature requests that could provide what you need, such as conditional fields, but no really great way to do it currently.

I’ll give you the best approach I can think of, but first the drawbacks:

  • Nothing will be shown for this field in the preview pane
  • Each collection that you want to search will have to be indicated in the field config (won’t automatically work for all collections - but I can’t imagine a future solution that wouldn’t require this)
  • You only need one value, but this approach will use a list, so you’d only use the first value in the list
  • Uses a beta feature, so the API might change

Here’s how it would work:

  1. Use the beta list types feature
  2. For each collection that you want to query, add a type whose fields consist of a relation widget

Users could then select the collection they want to query by selecting the “type” of list item they want to add, then query away. Besides the caveats mentioned above, I’m pretty sure this will work. If you try it let me know how it goes.

1 Like