Use case for a listing component

It would be nice to be able to take a look at your code.

I have an example on how to create a relations field that uses a catalog query for its data source. The vocabulary is defined like this:

and registered like this:

and the field that uses it looks like this:

Caveat, I don't know how well this would work on Volto, though, I've never tried it.

Ideally you would have something like this (and I hope I properly understood your requirements):

  • A Volto block that allows you to pick news items via a special widget. The Relations widget would work fine for this. You could implement something more fancy, but at its basics it would work like the relations widget.
  • The "database value" of the block would be a list of UIDs for the news items.
  • You would use the @search endpoint with the UIDs. Just an example that this works, https://biodiversity.europa.eu/search?UID=1fbc40827f2345a0b9a89892ff7e9686. I don't know if you can pass a list of UIDs to the search endpoint, I've tried https://biodiversity.europa.eu/search?UID:list:string=1fbc40827f2345a0b9a89892ff7e9686&UID:list:string=ac59022def9e47e4b1235b8a2c712880 and it didn't work. If you want to avoid multiple API calls, (in a custom Plone backend addon) you would write a new restapi endpoint service (something similar to the @search endpoint that, given a block uid, it would return the metadata for the related news items).

Except for the URL issue, it works somewhat like I wanted, but after I tested the schedule I found out there was an error occurring for anonymous users. I've no idea why this is happening yet, but I think it's trying to get the last "Featured Item" even though the user is not logged in and it's not the correct time to show it yet, so it's returning a null value instead of the last published item that the guest is allowed to see.

If I understand correctly, you have the Newsitem linked in the block, but the user is not able to see the details because that news item shouldn't actually be published yet. You'd have to "fix" what the anonymous user sees as the value for that block using a block serialization transformer. Basically, on the backend, in that transfomer, you'd get the actual news items, inspect them for publishing status and remove them from the response if they're not ready.

1 Like